ldtypes.cpp

Tue, 07 May 2013 00:22:01 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Tue, 07 May 2013 00:22:01 +0300
changeset 169
f562323760a2
parent 168
96691a009dff
child 170
2247a32e63a8
permissions
-rw-r--r--

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

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
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
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
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include "common.h"
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
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
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
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
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 "unknown",
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 "empty",
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
37 "unidentified",
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 };
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
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
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
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
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 // LDObject constructors
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 LDObject::LDObject () {
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
61 qObjListEntry = null;
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
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;
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65
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
66 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
67 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
68 zReason = _zReason;
73
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
69 }
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
70
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
71 // =============================================================================
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
72 str LDComment::getContents () {
164
8c93d8e38494 cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 162
diff changeset
73 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
74 }
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
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
76 str LDSubfile::getContents () {
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
77 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
78 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
79 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
80 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
81 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
82 }
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
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
84 str LDLine::getContents () {
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
85 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
86
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 for (ushort i = 0; i < 2; ++i)
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 134
diff changeset
88 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
89
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 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
91 }
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 str LDTriangle::getContents () {
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
94 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
95
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 for (ushort i = 0; i < 3; ++i)
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 134
diff changeset
97 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
98
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 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
100 }
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 str LDQuad::getContents () {
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
103 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
104
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 for (ushort i = 0; i < 4; ++i)
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 134
diff changeset
106 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
107
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 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
109 }
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 str LDCondLine::getContents () {
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
112 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
113
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
114 // Add the coordinates
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
115 for (ushort i = 0; i < 4; ++i)
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 134
diff changeset
116 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
117
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 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
119 }
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 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
122 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
123 }
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 str LDVertex::getContents () {
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
126 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
127 }
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 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
130 return str ();
21
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
131 }
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
132
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
133 // =============================================================================
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 // =============================================================================
164
8c93d8e38494 cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 162
diff changeset
136 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
137 "CERTIFY CCW",
73
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
138 "CCW",
88
652028158792 Allow the user to alter the tool bar icon size
Santeri Piippo <crimsondusk64@gmail.com>
parents: 84
diff changeset
139 "CERTIFY CW",
73
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
140 "CW",
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
141 "NOCERTIFY",
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
142 "INVERTNEXT",
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
143 };
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 str LDBFC::getContents () {
164
8c93d8e38494 cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 162
diff changeset
146 return fmt ("0 BFC %s", LDBFC::statements[type]);
73
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
147 }
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 vector<LDTriangle*> LDQuad::splitToTriangles () {
21
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
153 // Create the two triangles based on this quadrilateral:
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
154 // 0---3 0---3 3
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
155 // | | | / /|
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 // 1---2 1 1---2
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
159 LDTriangle* tri1 = new LDTriangle;
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
160 tri1->vaCoords[0] = vaCoords[0];
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
161 tri1->vaCoords[1] = vaCoords[1];
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
162 tri1->vaCoords[2] = vaCoords[3];
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
163
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
164 LDTriangle* tri2 = new LDTriangle;
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
165 tri2->vaCoords[0] = vaCoords[1];
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
166 tri2->vaCoords[1] = vaCoords[2];
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
167 tri2->vaCoords[2] = vaCoords[3];
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
168
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
169 // The triangles also inherit the quad's color
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
170 tri1->dColor = tri2->dColor = dColor;
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
171
73
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
172 vector<LDTriangle*> triangles;
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
173 triangles.push_back (tri1);
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
174 triangles.push_back (tri2);
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
175 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
176 }
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
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
178 // =============================================================================
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 // =============================================================================
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
181 void LDObject::replace (LDObject* replacement) {
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
182 // 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
183 for (LDObject*& obj : g_curfile->m_objs)
84
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
184 if (obj == this)
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
185 obj = replacement;
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
186
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
187 // Remove the old object
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
188 delete this;
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
189 }
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
190
84
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
191 // =============================================================================
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 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
195 for (LDObject*& obj : g_curfile->m_objs) {
84
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
196 if (obj == this)
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
197 obj = other;
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
198 else if (obj == other)
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
199 obj = this;
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
200 }
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
57
6e89589f1fe8 Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 50
diff changeset
203 LDLine::LDLine (vertex v1, vertex v2) {
6e89589f1fe8 Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 50
diff changeset
204 vaCoords[0] = v1;
6e89589f1fe8 Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 50
diff changeset
205 vaCoords[1] = v2;
6e89589f1fe8 Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 50
diff changeset
206 }
6e89589f1fe8 Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 50
diff changeset
207
108
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
208 LDObject::~LDObject () {
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
209 // 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
210 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
211 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
212 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
213 }
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
214
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
215 // =============================================================================
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 // =============================================================================
162
b7d65e89861a matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 161
diff changeset
218 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
219 switch (obj->getType()) {
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
220 case LDObject::Line:
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
221 case LDObject::CondLine:
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
222 case LDObject::Triangle:
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
223 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
224 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
225 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
226 break;
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
227
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
228 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
229 {
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 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
231
162
b7d65e89861a matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 161
diff changeset
232 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
233 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
234 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
235 }
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 break;
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
237
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
238 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
239 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
240 }
134
7fd0784471df Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 127
diff changeset
241
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 140
diff changeset
242 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
243 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
244 }
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
245
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 // =============================================================================
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
249 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
250 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
251
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
252 // 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
253 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
254 for (LDObject* obj : pFile->m_objCache)
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
255 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
256 } 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
257 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
258 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
259
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
260 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
261 // 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
262 switch (obj->getType ()) {
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
263 case LDObject::Comment:
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
264 case LDObject::Empty:
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
265 case LDObject::Gibberish:
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
266 case LDObject::Unidentified:
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
267 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
268 continue;
75
e95a00e34711 Don't include non-INVERTNEXT BFC statements in inlined objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 74
diff changeset
269
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
270 case LDObject::BFC:
75
e95a00e34711 Don't include non-INVERTNEXT BFC statements in inlined objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 74
diff changeset
271 // Filter non-INVERTNEXT statements
164
8c93d8e38494 cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 162
diff changeset
272 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
273 continue;
e95a00e34711 Don't include non-INVERTNEXT BFC statements in inlined objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 74
diff changeset
274 break;
e95a00e34711 Don't include non-INVERTNEXT BFC statements in inlined objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 74
diff changeset
275
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
276 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
277 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
278 }
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 // 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
281 // 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
282 // 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
283 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
284 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
285
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
286 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
287
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
288 for (LDObject* otherobj : otherobjs) {
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
289 // 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
290 if (bCache)
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
291 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
292
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
293 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
294 }
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
295 } 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
296 if (bCache)
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
297 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
298
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
299 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
300 }
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
301 }
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
302
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 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
304 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
305 }
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
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
307 // Transform the objects
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
308 for (LDObject* obj : objs) {
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
309 // Set the parent now so we know what inlined this.
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
310 obj->parent = this;
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
311
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
312 transformObject (obj, mMatrix, vPosition, dColor);
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
313 }
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
314
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 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
316 }
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 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
322 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
323 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
324 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
325
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 return -1;
91
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
327 }
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
328
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
329 // =============================================================================
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 // =============================================================================
91
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
332 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
333 // 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
334 const long start = bUp ? 0 : (objs.size() - 1);
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
335 const long end = bUp ? objs.size() : -1;
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
336 const long incr = bUp ? 1 : -1;
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
337
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
338 for (long i = start; i != end; i += incr) {
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
339 LDObject* obj = objs[i];
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
340
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
341 const long lIndex = obj->getIndex (g_curfile),
91
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
342 lTarget = lIndex + (bUp ? -1 : 1);
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
343
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
344 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
345 (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
346 {
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
347 // 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
348 // 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
349 // abort the entire operation.
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
350 assert (i == start);
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
351 return;
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
352 }
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
353
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
354 obj->swap (g_curfile->m_objs[lTarget]);
91
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
355 }
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
356 }
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 // =============================================================================
117
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
361 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
362 bool firstDetails = true;
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
363 str text = "";
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
364
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
365 if (objs.size() == 0)
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
366 return "nothing"; // :)
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
367
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
368 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
369 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
370 ulong objCount = 0;
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
371
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
372 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
373 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
374 objCount++;
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
375
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
376 if (objCount == 0)
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
377 continue;
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
378
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
379 if (!firstDetails)
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
380 text += ", ";
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
381
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
382 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
383
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
384 // 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
385 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
386 noun = "vertices";
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
387
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
388 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
389 firstDetails = false;
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
390 }
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
391
140
2e8c1626aef7 Added insert from action to import file contents from another file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 138
diff changeset
392 return text;
102
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
393 }
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 // =============================================================================
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
396 LDObject* LDObject::topLevelParent () {
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
397 if (!parent)
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
398 return null;
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
399
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
400 LDObject* it = this;
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
401
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
402 while (it->parent)
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
403 it = it->parent;
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
404
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
405 return it;
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
406 }
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
407
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
408
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
409 // =============================================================================
102
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
410 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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 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
413 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
414 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
415 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
416 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
417
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
418 void LDVertex::move (vertex vVector) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
419 vPosition += vVector;
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
420 }
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 void LDSubfile::move (vertex vVector) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
423 vPosition += vVector;
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
424 }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
425
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
426 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
427 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
428 }
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
102
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
430 void LDLine::move (vertex vVector) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
431 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
432 vaCoords[i] += vVector;
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
433 }
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 void LDTriangle::move (vertex vVector) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
436 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
437 vaCoords[i] += vVector;
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
438 }
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 void LDQuad::move (vertex vVector) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
441 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
442 vaCoords[i] += vVector;
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
443 }
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 void LDCondLine::move (vertex vVector) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
446 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
447 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
448 }
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
113
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
450 // =============================================================================
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
451 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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 // =============================================================================
113
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
453 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
454 "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
455 "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
456 "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
457 "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
458 "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
459 "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
460 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
461 };
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
113
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
463 char const* LDRadial::radialTypeName () {
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
464 return g_saRadialTypeNames[eRadialType];
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
465 }
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 char const* LDRadial::radialTypeName (const LDRadial::Type eType) {
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
468 return g_saRadialTypeNames[eType];
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
469 }
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 // =============================================================================
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
474 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
475 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
476
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 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
478 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
479 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
480 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
481 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
482
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 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
484 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
485 {
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 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
487 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
488
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 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
490 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
491 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
492 }
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 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
495 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
496 pLine->vaCoords[1] = v1;
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 140
diff changeset
497 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
498 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
499
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 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
501 }
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 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
503
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 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
505 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
506 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
507 {
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 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
509 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
510
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 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
512 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
513 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
514 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
515 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
516
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 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
518 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
519 } 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
520 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
521 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
522 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
523 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
524
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 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
526 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
527 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
528 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
529
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 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
531 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
532 } 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
533 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
534 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
535 }
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 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
539 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
540 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
541 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
542
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 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
544 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
545 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
546 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
547 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
548 }
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 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
551 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
552 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
553 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
554 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
555 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
556 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
557
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 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
559 }
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 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
561
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 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
563 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
564 {
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 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
566
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 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
568 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
569 } 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
570 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
571 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
572 }
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 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
575 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
576 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
577
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 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
579 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
580 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
581 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
582 }
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 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
585 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
586 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
587 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
588 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
589 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
590
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 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
592 }
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 break;
113
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
594
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
595 default:
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
596 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
597 }
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 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
601 }
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
114
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
603 // =============================================================================
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 // =============================================================================
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
606 str LDRadial::getContents () {
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
607 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
608 str (radialTypeName()).toupper ().strip (' ').chars (),
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
609 dColor, dSegments, dDivisions, dRingNum,
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 134
diff changeset
610 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
611 }
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 char const* g_saRadialNameRoots[] = {
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
614 "edge",
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
615 "cyli",
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
616 "disc",
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
617 "ndis",
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
618 "ring",
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
619 "cone",
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
620 null
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
621 };
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 str LDRadial::makeFileName () {
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
627 short numer = dSegments,
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
628 denom = dDivisions;
114
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
629
164
8c93d8e38494 cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 162
diff changeset
630 // 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
631 simplify (numer, denom);
114
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
632
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
633 if (denom < 4) {
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
634 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
635
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
636 numer *= factor;
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 164
diff changeset
637 denom *= factor;
114
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
638 }
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 // 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
641 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
642 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
643 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
644 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
645
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
646 // 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
647 // 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
648 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
649 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
650
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
651 // 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
652 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
653 }
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 #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
659 if (type == LDObject::N) \
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
660 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
661 LDObject* LDObject::getDefault (const LDObject::Type type) {
138
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
662 CHECK_FOR_OBJ (Comment)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
663 CHECK_FOR_OBJ (BFC)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
664 CHECK_FOR_OBJ (Line)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
665 CHECK_FOR_OBJ (CondLine)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
666 CHECK_FOR_OBJ (Radial)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
667 CHECK_FOR_OBJ (Subfile)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
668 CHECK_FOR_OBJ (Triangle)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
669 CHECK_FOR_OBJ (Quad)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
670 CHECK_FOR_OBJ (Empty)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
671 CHECK_FOR_OBJ (BFC)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
672 CHECK_FOR_OBJ (Gibberish)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
673 CHECK_FOR_OBJ (Vertex)
d22d5c1d9e8a Added new subfile dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
674 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
675 }

mercurial