Tue, 07 May 2013 01:15:31 +0300
Added visibility toggling
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
1 | /* |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
104 | 3 | * Copyright (C) 2013 Santeri Piippo |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
4 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
8 | * (at your option) any later version. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
9 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
13 | * GNU General Public License for more details. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
14 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
17 | */ |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
18 | |
0 | 19 | #include "common.h" |
20 | #include "ldtypes.h" | |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
21 | #include "file.h" |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
22 | #include "misc.h" |
108
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
23 | #include "gui.h" |
0 | 24 | |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
25 | char const* g_saObjTypeNames[] = { |
96
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
26 | "subfile", |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
27 | "radial", |
96
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
28 | "quadrilateral", |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
29 | "triangle", |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
30 | "line", |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
31 | "condline", |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
32 | "vertex", |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
33 | "bfc", |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
34 | "comment", |
0 | 35 | "unknown", |
36 | "empty", | |
96
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
37 | "unidentified", |
0 | 38 | }; |
39 | ||
96
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
40 | // Should probably get rid of this array sometime |
39
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
41 | char const* g_saObjTypeIcons[] = { |
96
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
42 | "subfile", |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
43 | "radial", |
96
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
44 | "quad", |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
45 | "triangle", |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
46 | "line", |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
47 | "condline", |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
48 | "vertex", |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
49 | "bfc", |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
50 | "comment", |
41
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
51 | "error", |
4ca63da5546b
Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
40
diff
changeset
|
52 | "empty", |
96
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
53 | "error", |
39
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
54 | }; |
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
55 | |
0 | 56 | // ============================================================================= |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
57 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
58 | // ============================================================================= |
0 | 59 | // LDObject constructors |
60 | LDObject::LDObject () { | |
104 | 61 | qObjListEntry = null; |
62 | parent = null; | |
169
f562323760a2
Added grouping basics - will be needed for ext programs (Intersector, Isecalc and a lot of others use 2 or more inputs, need to get all of those in somehow...) plus I think they can be useful for the actual authoring process
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
63 | m_group = NoGroup; |
170
2247a32e63a8
Added visibility toggling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
169
diff
changeset
|
64 | m_hidden = false; |
0 | 65 | } |
66 | ||
11
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
67 | LDGibberish::LDGibberish (str _zContent, str _zReason) { |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
68 | zContents = _zContent; |
11
323390a03294
Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
69 | zReason = _zReason; |
73
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
70 | } |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
71 | |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
72 | // ============================================================================= |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
73 | str LDComment::getContents () { |
164 | 74 | return fmt ("0 %s", text.chars ()); |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
75 | } |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
76 | |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
77 | str LDSubfile::getContents () { |
161 | 78 | str val = fmt ("1 %d %s ", dColor, vPosition.stringRep (false).chars ()); |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
134
diff
changeset
|
79 | val += mMatrix.stringRep (); |
127
a6e2067bb2f1
Keep track of when the file was last saved and warn if there are unsaved changes when the application is closing.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
117
diff
changeset
|
80 | val += ' '; |
65
e4f25b44e240
Reverted changes on LDSubfile::getContents, I had a temporary, hackier solution there and forgot to change it back
Santeri Piippo <crimsondusk64@gmail.com>
parents:
64
diff
changeset
|
81 | val += zFileName; |
e4f25b44e240
Reverted changes on LDSubfile::getContents, I had a temporary, hackier solution there and forgot to change it back
Santeri Piippo <crimsondusk64@gmail.com>
parents:
64
diff
changeset
|
82 | return val; |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
83 | } |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
84 | |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
85 | str LDLine::getContents () { |
161 | 86 | str val = fmt ("2 %d", dColor); |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
87 | |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
88 | for (ushort i = 0; i < 2; ++i) |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
134
diff
changeset
|
89 | val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
90 | |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
91 | return val; |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
92 | } |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
93 | |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
94 | str LDTriangle::getContents () { |
161 | 95 | str val = fmt ("3 %d", dColor); |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
96 | |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
97 | for (ushort i = 0; i < 3; ++i) |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
134
diff
changeset
|
98 | val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
99 | |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
100 | return val; |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
101 | } |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
102 | |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
103 | str LDQuad::getContents () { |
161 | 104 | str val = fmt ("4 %d", dColor); |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
105 | |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
106 | for (ushort i = 0; i < 4; ++i) |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
134
diff
changeset
|
107 | val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
108 | |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
109 | return val; |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
110 | } |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
111 | |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
112 | str LDCondLine::getContents () { |
161 | 113 | str val = fmt ("5 %d", dColor); |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
114 | |
40
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
115 | // Add the coordinates |
215b9f8f0cd7
Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
116 | for (ushort i = 0; i < 4; ++i) |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
134
diff
changeset
|
117 | val.appendformat (" %s", vaCoords[i].stringRep (false).chars ()); |
18
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
118 | |
a6732098fed8
Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
17
diff
changeset
|
119 | return val; |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
120 | } |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
121 | |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
122 | str LDGibberish::getContents () { |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
123 | return zContents; |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
124 | } |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
125 | |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
126 | str LDVertex::getContents () { |
161 | 127 | return fmt ("0 !LDFORGE VERTEX %d %s", dColor, vPosition.stringRep (false).chars()); |
14
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
128 | } |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
129 | |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
130 | str LDEmpty::getContents () { |
6d9d8efae2f8
this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
131 | return str (); |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
132 | } |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
133 | |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
134 | // ============================================================================= |
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
135 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
136 | // ============================================================================= |
164 | 137 | const char* LDBFC::statements[] = { |
88
652028158792
Allow the user to alter the tool bar icon size
Santeri Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
138 | "CERTIFY CCW", |
73
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
139 | "CCW", |
88
652028158792
Allow the user to alter the tool bar icon size
Santeri Piippo <crimsondusk64@gmail.com>
parents:
84
diff
changeset
|
140 | "CERTIFY CW", |
73
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
141 | "CW", |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
142 | "NOCERTIFY", |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
143 | "INVERTNEXT", |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
144 | }; |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
145 | |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
146 | str LDBFC::getContents () { |
164 | 147 | return fmt ("0 BFC %s", LDBFC::statements[type]); |
73
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
148 | } |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
149 | |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
150 | // ============================================================================= |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
151 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
152 | // ============================================================================= |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
153 | vector<LDTriangle*> LDQuad::splitToTriangles () { |
21
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
154 | // Create the two triangles based on this quadrilateral: |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
155 | // 0---3 0---3 3 |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
156 | // | | | / /| |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
157 | // | | = | / / | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
158 | // | | |/ / | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
159 | // 1---2 1 1---2 |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
160 | LDTriangle* tri1 = new LDTriangle; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
161 | tri1->vaCoords[0] = vaCoords[0]; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
162 | tri1->vaCoords[1] = vaCoords[1]; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
163 | tri1->vaCoords[2] = vaCoords[3]; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
164 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
165 | LDTriangle* tri2 = new LDTriangle; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
166 | tri2->vaCoords[0] = vaCoords[1]; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
167 | tri2->vaCoords[1] = vaCoords[2]; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
168 | tri2->vaCoords[2] = vaCoords[3]; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
169 | |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
170 | // The triangles also inherit the quad's color |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
171 | tri1->dColor = tri2->dColor = dColor; |
9aebaaafa5da
Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
172 | |
73
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
173 | vector<LDTriangle*> triangles; |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
174 | triangles.push_back (tri1); |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
175 | triangles.push_back (tri2); |
d20867ac03cc
Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
176 | return triangles; |
24
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
22
diff
changeset
|
177 | } |
d2d4d0154338
added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
22
diff
changeset
|
178 | |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
179 | // ============================================================================= |
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
180 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
181 | // ============================================================================= |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
182 | void LDObject::replace (LDObject* replacement) { |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
183 | // Replace all instances of the old object with the new object |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
184 | for (LDObject*& obj : g_curfile->m_objs) |
84
c9438ea54ed9
Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
185 | if (obj == this) |
c9438ea54ed9
Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
186 | obj = replacement; |
29
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
187 | |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
188 | // Remove the old object |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
189 | delete this; |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
190 | } |
55406ce7446e
Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
191 | |
84
c9438ea54ed9
Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
192 | // ============================================================================= |
c9438ea54ed9
Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
193 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
c9438ea54ed9
Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
194 | // ============================================================================= |
c9438ea54ed9
Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
195 | void LDObject::swap (LDObject* other) { |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
196 | for (LDObject*& obj : g_curfile->m_objs) { |
84
c9438ea54ed9
Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
197 | if (obj == this) |
c9438ea54ed9
Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
198 | obj = other; |
c9438ea54ed9
Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
199 | else if (obj == other) |
c9438ea54ed9
Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
200 | obj = this; |
c9438ea54ed9
Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
201 | } |
c9438ea54ed9
Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
202 | } |
c9438ea54ed9
Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
76
diff
changeset
|
203 | |
57
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
204 | LDLine::LDLine (vertex v1, vertex v2) { |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
205 | vaCoords[0] = v1; |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
206 | vaCoords[1] = v2; |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
207 | } |
6e89589f1fe8
Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
208 | |
108
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
209 | LDObject::~LDObject () { |
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
210 | // Remove this object from the selection array if it is there. |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
211 | for (ulong i = 0; i < g_win->sel ().size(); ++i) |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
212 | if (g_win->sel ()[i] == this) |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
213 | g_win->sel ().erase (g_win->sel ().begin() + i); |
108
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
214 | } |
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
215 | |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
216 | // ============================================================================= |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
217 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
218 | // ============================================================================= |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
161
diff
changeset
|
219 | static void transformObject (LDObject* obj, matrix<3> transform, vertex pos, short parentcolor) { |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
220 | switch (obj->getType()) { |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
221 | case LDObject::Line: |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
222 | case LDObject::CondLine: |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
223 | case LDObject::Triangle: |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
224 | case LDObject::Quad: |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
127
diff
changeset
|
225 | for (short i = 0; i < obj->vertices (); ++i) |
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
127
diff
changeset
|
226 | obj->vaCoords[i].transform (transform, pos); |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
227 | break; |
76
42284126072a
Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
75
diff
changeset
|
228 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
229 | case LDObject::Subfile: |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
230 | { |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
231 | LDSubfile* ref = static_cast<LDSubfile*> (obj); |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
232 | |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
161
diff
changeset
|
233 | matrix<3> newMatrix = transform * ref->mMatrix; |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
127
diff
changeset
|
234 | ref->vPosition.transform (transform, pos); |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
161
diff
changeset
|
235 | ref->mMatrix = newMatrix; |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
236 | } |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
237 | break; |
76
42284126072a
Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
75
diff
changeset
|
238 | |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
239 | default: |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
240 | break; |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
241 | } |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
127
diff
changeset
|
242 | |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
140
diff
changeset
|
243 | if (obj->dColor == maincolor) |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
127
diff
changeset
|
244 | obj->dColor = parentcolor; |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
245 | } |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
246 | |
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
247 | // ============================================================================= |
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
248 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
249 | // ============================================================================= |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
250 | vector<LDObject*> LDSubfile::inlineContents (bool bDeepInline, bool bCache) { |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
251 | vector<LDObject*> objs, cache; |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
252 | |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
253 | // If we have this cached, just clone that |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
254 | if (bDeepInline && pFile->m_objCache.size ()) { |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
255 | for (LDObject* obj : pFile->m_objCache) |
76
42284126072a
Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
75
diff
changeset
|
256 | objs.push_back (obj->clone ()); |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
257 | } else { |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
258 | if (!bDeepInline) |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
259 | bCache = false; |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
260 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
261 | for (LDObject* obj : pFile->m_objs) { |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
262 | // Skip those without schemantic meaning |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
263 | switch (obj->getType ()) { |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
264 | case LDObject::Comment: |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
265 | case LDObject::Empty: |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
266 | case LDObject::Gibberish: |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
267 | case LDObject::Unidentified: |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
268 | case LDObject::Vertex: |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
269 | continue; |
75
e95a00e34711
Don't include non-INVERTNEXT BFC statements in inlined objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
74
diff
changeset
|
270 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
271 | case LDObject::BFC: |
75
e95a00e34711
Don't include non-INVERTNEXT BFC statements in inlined objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
74
diff
changeset
|
272 | // Filter non-INVERTNEXT statements |
164 | 273 | if (static_cast<LDBFC*> (obj)->type != LDBFC::InvertNext) |
75
e95a00e34711
Don't include non-INVERTNEXT BFC statements in inlined objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
74
diff
changeset
|
274 | continue; |
e95a00e34711
Don't include non-INVERTNEXT BFC statements in inlined objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
74
diff
changeset
|
275 | break; |
e95a00e34711
Don't include non-INVERTNEXT BFC statements in inlined objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
74
diff
changeset
|
276 | |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
277 | default: |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
278 | break; |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
279 | } |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
280 | |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
281 | // Got another sub-file reference, inline it if we're deep-inlining. If not, |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
282 | // just add it into the objects normally. Also, we only cache immediate |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
283 | // subfiles and this is not one. Yay, recursion! |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
284 | if (bDeepInline && obj->getType() == LDObject::Subfile) { |
63
aa40ce18f869
Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
285 | LDSubfile* ref = static_cast<LDSubfile*> (obj); |
aa40ce18f869
Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
286 | |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
287 | vector<LDObject*> otherobjs = ref->inlineContents (true, false); |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
288 | |
69
6790dea720a8
Simplified configuration code. Use a std::vector object to contain config pointers and have config objects register themselves upon creation instead of relying on a cfgdefs.h. Removed sections, all configurations are just simply written one after another now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
289 | for (LDObject* otherobj : otherobjs) { |
76
42284126072a
Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
75
diff
changeset
|
290 | // Cache this object, if desired |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
291 | if (bCache) |
76
42284126072a
Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
75
diff
changeset
|
292 | cache.push_back (otherobj->clone ()); |
63
aa40ce18f869
Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
293 | |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
294 | objs.push_back (otherobj); |
63
aa40ce18f869
Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
295 | } |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
296 | } else { |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
297 | if (bCache) |
76
42284126072a
Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
75
diff
changeset
|
298 | cache.push_back (obj->clone ()); |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
299 | |
76
42284126072a
Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
75
diff
changeset
|
300 | objs.push_back (obj->clone ()); |
63
aa40ce18f869
Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
301 | } |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
302 | } |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
303 | |
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
304 | if (bCache) |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
305 | pFile->m_objCache = cache; |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
306 | } |
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
307 | |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
308 | // Transform the objects |
104 | 309 | for (LDObject* obj : objs) { |
310 | // Set the parent now so we know what inlined this. | |
311 | obj->parent = this; | |
312 | ||
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
313 | transformObject (obj, mMatrix, vPosition, dColor); |
104 | 314 | } |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
315 | |
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
316 | return objs; |
63
aa40ce18f869
Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
317 | } |
aa40ce18f869
Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
318 | |
aa40ce18f869
Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
319 | // ============================================================================= |
aa40ce18f869
Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
320 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
aa40ce18f869
Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
321 | // ============================================================================= |
aa40ce18f869
Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
322 | long LDObject::getIndex (OpenFile* pFile) { |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
323 | for (ulong i = 0; i < pFile->m_objs.size(); ++i) |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
324 | if (pFile->m_objs[i] == this) |
74
1affec15e572
LDObject::getIndex was bogus which would cause inlining to crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
73
diff
changeset
|
325 | return i; |
63
aa40ce18f869
Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
326 | |
aa40ce18f869
Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
327 | return -1; |
91
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
328 | } |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
329 | |
96
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
330 | // ============================================================================= |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
331 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
332 | // ============================================================================= |
91
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
333 | void LDObject::moveObjects (std::vector<LDObject*> objs, const bool bUp) { |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
334 | // If we move down, we need to iterate the array in reverse order. |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
335 | const long start = bUp ? 0 : (objs.size() - 1); |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
336 | const long end = bUp ? objs.size() : -1; |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
337 | const long incr = bUp ? 1 : -1; |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
338 | |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
339 | for (long i = start; i != end; i += incr) { |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
340 | LDObject* obj = objs[i]; |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
341 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
342 | const long lIndex = obj->getIndex (g_curfile), |
91
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
343 | lTarget = lIndex + (bUp ? -1 : 1); |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
344 | |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
345 | if ((bUp == true and lIndex == 0) or |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
346 | (bUp == false and lIndex == (long)(g_curfile->m_objs.size() - 1))) |
91
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
347 | { |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
348 | // One of the objects hit the extrema. If this happens, this should be the first |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
349 | // object to be iterated on. Thus, nothing has changed yet and it's safe to just |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
350 | // abort the entire operation. |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
351 | assert (i == start); |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
352 | return; |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
353 | } |
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
354 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
355 | obj->swap (g_curfile->m_objs[lTarget]); |
91
b4dda6348e7e
History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents:
90
diff
changeset
|
356 | } |
96
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
357 | } |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
358 | |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
359 | // ============================================================================= |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
360 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
361 | // ============================================================================= |
117
7eb7a43a511b
Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents:
116
diff
changeset
|
362 | str LDObject::objectListContents (const std::vector<LDObject*>& objs) { |
140
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
363 | bool firstDetails = true; |
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
364 | str text = ""; |
96
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
365 | |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
366 | if (objs.size() == 0) |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
367 | return "nothing"; // :) |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
368 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
369 | for (long i = 0; i < LDObject::NumTypes; ++i) { |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
370 | LDObject::Type objType = (LDObject::Type) i; |
140
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
371 | ulong objCount = 0; |
96
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
372 | |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
373 | for (LDObject* obj : objs) |
140
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
374 | if (obj->getType() == objType) |
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
375 | objCount++; |
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
376 | |
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
377 | if (objCount == 0) |
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
378 | continue; |
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
379 | |
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
380 | if (!firstDetails) |
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
381 | text += ", "; |
96
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
382 | |
161 | 383 | str noun = fmt ("%s%s", g_saObjTypeNames[objType], PLURAL (objCount)); |
140
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
384 | |
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
385 | // Plural of "vertex" is "vertices". Stupid English. |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
386 | if (objType == LDObject::Vertex && objCount != 1) |
140
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
387 | noun = "vertices"; |
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
388 | |
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
389 | text.appendformat ("%lu %s", objCount, noun.chars ()); |
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
390 | firstDetails = false; |
96
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
391 | } |
2f175b3d8211
Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents:
91
diff
changeset
|
392 | |
140
2e8c1626aef7
Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents:
138
diff
changeset
|
393 | return text; |
102
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
394 | } |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
395 | |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
396 | // ============================================================================= |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
397 | LDObject* LDObject::topLevelParent () { |
104 | 398 | if (!parent) |
399 | return null; | |
400 | ||
401 | LDObject* it = this; | |
402 | ||
403 | while (it->parent) | |
404 | it = it->parent; | |
405 | ||
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
406 | return it; |
104 | 407 | } |
408 | ||
409 | ||
410 | // ============================================================================= | |
102
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
411 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
412 | // ============================================================================= |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
413 | void LDObject::move (vertex vVector) { vVector = vVector; /* to shut up GCC */ } |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
414 | void LDEmpty::move (vertex vVector) { vVector = vVector; } |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
415 | void LDBFC::move (vertex vVector) { vVector = vVector; } |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
416 | void LDComment::move (vertex vVector) { vVector = vVector; } |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
417 | void LDGibberish::move (vertex vVector) { vVector = vVector; } |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
418 | |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
419 | void LDVertex::move (vertex vVector) { |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
420 | vPosition += vVector; |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
421 | } |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
422 | |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
423 | void LDSubfile::move (vertex vVector) { |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
424 | vPosition += vVector; |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
425 | } |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
426 | |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
427 | void LDRadial::move (vertex vVector) { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
428 | vPosition += vVector; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
429 | } |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
430 | |
102
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
431 | void LDLine::move (vertex vVector) { |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
432 | for (short i = 0; i < 2; ++i) |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
433 | vaCoords[i] += vVector; |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
434 | } |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
435 | |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
436 | void LDTriangle::move (vertex vVector) { |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
437 | for (short i = 0; i < 3; ++i) |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
438 | vaCoords[i] += vVector; |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
439 | } |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
440 | |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
441 | void LDQuad::move (vertex vVector) { |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
442 | for (short i = 0; i < 4; ++i) |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
443 | vaCoords[i] += vVector; |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
444 | } |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
445 | |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
446 | void LDCondLine::move (vertex vVector) { |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
447 | for (short i = 0; i < 4; ++i) |
cacd4681ccb4
Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
96
diff
changeset
|
448 | vaCoords[i] += vVector; |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
449 | } |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
450 | |
113
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
451 | // ============================================================================= |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
452 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
453 | // ============================================================================= |
113
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
454 | static char const* g_saRadialTypeNames[] = { |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
455 | "Circle", |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
456 | "Cylinder", |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
457 | "Disc", |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
458 | "Disc Negative", |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
459 | "Ring", |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
460 | "Cone", |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
461 | null |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
462 | }; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
463 | |
113
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
464 | char const* LDRadial::radialTypeName () { |
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
465 | return g_saRadialTypeNames[eRadialType]; |
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
466 | } |
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
467 | |
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
468 | char const* LDRadial::radialTypeName (const LDRadial::Type eType) { |
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
469 | return g_saRadialTypeNames[eType]; |
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
470 | } |
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
471 | |
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
472 | // ============================================================================= |
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
473 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
474 | // ============================================================================= |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
475 | std::vector<LDObject*> LDRadial::decompose (bool bTransform) { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
476 | std::vector<LDObject*> paObjects; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
477 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
478 | for (short i = 0; i < dSegments; ++i) { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
479 | double x0 = cos ((i * 2 * pi) / dDivisions), |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
480 | x1 = cos (((i + 1) * 2 * pi) / dDivisions), |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
481 | z0 = sin ((i * 2 * pi) / dDivisions), |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
482 | z1 = sin (((i + 1) * 2 * pi) / dDivisions); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
483 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
484 | switch (eRadialType) { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
485 | case LDRadial::Circle: |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
486 | { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
487 | vertex v0 (x0, 0.0f, z0), |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
488 | v1 (x1, 0.0f, z1); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
489 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
490 | if (bTransform) { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
491 | v0.transform (mMatrix, vPosition); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
492 | v1.transform (mMatrix, vPosition); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
493 | } |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
494 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
495 | LDLine* pLine = new LDLine; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
496 | pLine->vaCoords[0] = v0; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
497 | pLine->vaCoords[1] = v1; |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
140
diff
changeset
|
498 | pLine->dColor = edgecolor; |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
499 | pLine->parent = this; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
500 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
501 | paObjects.push_back (pLine); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
502 | } |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
503 | break; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
504 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
505 | case LDRadial::Cylinder: |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
506 | case LDRadial::Ring: |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
507 | case LDRadial::Cone: |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
508 | { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
509 | double x2, x3, z2, z3; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
510 | double y0, y1, y2, y3; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
511 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
512 | if (eRadialType == LDRadial::Cylinder) { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
513 | x2 = x1; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
514 | x3 = x0; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
515 | z2 = z1; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
516 | z3 = z0; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
517 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
518 | y0 = y1 = 0.0f; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
519 | y2 = y3 = 1.0f; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
520 | } else { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
521 | x2 = x1 * (dRingNum + 1); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
522 | x3 = x0 * (dRingNum + 1); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
523 | z2 = z1 * (dRingNum + 1); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
524 | z3 = z0 * (dRingNum + 1); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
525 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
526 | x0 *= dRingNum; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
527 | x1 *= dRingNum; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
528 | z0 *= dRingNum; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
529 | z1 *= dRingNum; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
530 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
531 | if (eRadialType == LDRadial::Ring) { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
532 | y0 = y1 = y2 = y3 = 0.0f; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
533 | } else { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
534 | y0 = y1 = 1.0f; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
535 | y2 = y3 = 0.0f; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
536 | } |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
537 | } |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
538 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
539 | vertex v0 (x0, y0, z0), |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
540 | v1 (x1, y1, z1), |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
541 | v2 (x2, y2, z2), |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
542 | v3 (x3, y3, z3); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
543 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
544 | if (bTransform) { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
545 | v0.transform (mMatrix, vPosition); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
546 | v1.transform (mMatrix, vPosition); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
547 | v2.transform (mMatrix, vPosition); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
548 | v3.transform (mMatrix, vPosition); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
549 | } |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
550 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
551 | LDQuad* pQuad = new LDQuad; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
552 | pQuad->vaCoords[0] = v0; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
553 | pQuad->vaCoords[1] = v1; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
554 | pQuad->vaCoords[2] = v2; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
555 | pQuad->vaCoords[3] = v3; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
556 | pQuad->dColor = dColor; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
557 | pQuad->parent = this; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
558 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
559 | paObjects.push_back (pQuad); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
560 | } |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
561 | break; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
562 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
563 | case LDRadial::Disc: |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
564 | case LDRadial::DiscNeg: |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
565 | { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
566 | double x2, z2; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
567 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
568 | if (eRadialType == LDRadial::Disc) { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
569 | x2 = z2 = 0.0f; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
570 | } else { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
571 | x2 = (x0 >= 0.0f) ? 1.0f : -1.0f; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
572 | z2 = (z0 >= 0.0f) ? 1.0f : -1.0f; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
573 | } |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
574 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
575 | vertex v0 (x0, 0.0f, z0), |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
576 | v1 (x1, 0.0f, z1), |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
577 | v2 (x2, 0.0f, z2); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
578 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
579 | if (bTransform) { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
580 | v0.transform (mMatrix, vPosition); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
581 | v1.transform (mMatrix, vPosition); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
582 | v2.transform (mMatrix, vPosition); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
583 | } |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
584 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
585 | LDTriangle* pSeg = new LDTriangle; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
586 | pSeg->vaCoords[0] = v0; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
587 | pSeg->vaCoords[1] = v1; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
588 | pSeg->vaCoords[2] = v2; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
589 | pSeg->dColor = dColor; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
590 | pSeg->parent = this; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
591 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
592 | paObjects.push_back (pSeg); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
593 | } |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
594 | break; |
113
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
595 | |
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
596 | default: |
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
597 | break; |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
598 | } |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
599 | } |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
600 | |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
601 | return paObjects; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
602 | } |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
603 | |
114
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
604 | // ============================================================================= |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
605 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
606 | // ============================================================================= |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
607 | str LDRadial::getContents () { |
161 | 608 | return fmt ("0 !LDFORGE RADIAL %s %d %d %d %d %s %s", |
113
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
609 | str (radialTypeName()).toupper ().strip (' ').chars (), |
bbaa40226ec9
Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
111
diff
changeset
|
610 | dColor, dSegments, dDivisions, dRingNum, |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
134
diff
changeset
|
611 | vPosition.stringRep (false).chars(), mMatrix.stringRep().chars()); |
114
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
612 | } |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
613 | |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
614 | char const* g_saRadialNameRoots[] = { |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
615 | "edge", |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
616 | "cyli", |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
617 | "disc", |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
618 | "ndis", |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
619 | "ring", |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
620 | "cone", |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
621 | null |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
622 | }; |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
623 | |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
624 | // ============================================================================= |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
625 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
626 | // ============================================================================= |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
627 | str LDRadial::makeFileName () { |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
628 | short numer = dSegments, |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
629 | denom = dDivisions; |
114
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
630 | |
164 | 631 | // Simplify the fractional part, but the denominator must be at least 4. |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
632 | simplify (numer, denom); |
114
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
633 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
634 | if (denom < 4) { |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
635 | const short factor = (4 / denom); |
114
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
636 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
637 | numer *= factor; |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
638 | denom *= factor; |
114
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
639 | } |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
640 | |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
641 | // Compose some general information: prefix, fraction, root, ring number |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
642 | str prefix = (dDivisions == 16) ? "" : fmt ("%d/", dDivisions); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
643 | str frac = fmt ("%d-%d", numer, denom); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
644 | str root = g_saRadialNameRoots[eRadialType]; |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
645 | str ringNum = (eRadialType == Ring || eRadialType == Cone) ? fmt ("%d", dRingNum) : ""; |
114
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
646 | |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
647 | // Truncate the root if necessary (7-16rin4.dat for instance). |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
648 | // However, always keep the root at least 2 characters. |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
649 | short extra = (~frac + ~ringNum + ~root) - 8; |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
650 | root -= min<short> (max<short> (extra, 0), 2); |
114
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
651 | |
fe1bfc5f59ed
Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
113
diff
changeset
|
652 | // Stick them all together and return the result. |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
653 | return fmt ("%s%s%s%s", prefix.chars(), frac.chars (), root.chars (), ringNum.chars ()); |
138
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
654 | } |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
655 | |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
656 | // ============================================================================= |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
657 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
658 | // ============================================================================= |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
659 | #define CHECK_FOR_OBJ(N) \ |
169
f562323760a2
Added grouping basics - will be needed for ext programs (Intersector, Isecalc and a lot of others use 2 or more inputs, need to get all of those in somehow...) plus I think they can be useful for the actual authoring process
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
660 | if (type == LDObject::N) \ |
138
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
661 | return new LD##N; |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
662 | LDObject* LDObject::getDefault (const LDObject::Type type) { |
138
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
663 | CHECK_FOR_OBJ (Comment) |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
664 | CHECK_FOR_OBJ (BFC) |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
665 | CHECK_FOR_OBJ (Line) |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
666 | CHECK_FOR_OBJ (CondLine) |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
667 | CHECK_FOR_OBJ (Radial) |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
668 | CHECK_FOR_OBJ (Subfile) |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
669 | CHECK_FOR_OBJ (Triangle) |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
670 | CHECK_FOR_OBJ (Quad) |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
671 | CHECK_FOR_OBJ (Empty) |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
672 | CHECK_FOR_OBJ (BFC) |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
673 | CHECK_FOR_OBJ (Gibberish) |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
674 | CHECK_FOR_OBJ (Vertex) |
d22d5c1d9e8a
Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
675 | return null; |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
676 | } |