src/gldata.cc

Mon, 20 Jan 2014 16:42:18 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Mon, 20 Jan 2014 16:42:18 +0200
changeset 668
6a05c4969074
child 671
14a6da9c0bfe
permissions
-rw-r--r--

- now compiles again

668
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 #include <cstring>
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 #include "gldata.h"
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 #include "ldtypes.h"
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 #include "colors.h"
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 #include "document.h"
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 #include "misc.h"
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 #include "gldraw.h"
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 #include <QDate>
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 #define DEBUG_PRINT(...) fprint (stdout, __VA_ARGS__)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 extern_cfg (Bool, gl_blackedges);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 static QList<short> g_warnedColors;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 VertexCompiler g_vertexCompiler;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18 VertexCompiler::Array::Array() :
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 m_data (null)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 clear();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 VertexCompiler::Array::~Array()
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 delete[] m_data;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 void VertexCompiler::Array::clear()
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 delete[] m_data;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 m_data = new Vertex[64];
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 m_size = 64;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 m_ptr = &m_data[0];
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 void VertexCompiler::Array::resizeToFit (Size newSize)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 if (allocatedSize() >= newSize)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 return;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 int32 cachedWriteSize = writtenSize();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 // Add some lee-way space to reduce the amount of resizing.
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 newSize += 256;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 const Size oldSize = allocatedSize();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 // We need to back up the data first
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 Vertex* copy = new Vertex[oldSize];
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 memcpy (copy, m_data, oldSize);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 // Re-create the buffer
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 delete[] m_data;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 m_data = new Vertex[newSize];
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 m_size = newSize;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 m_ptr = &m_data[cachedWriteSize / sizeof (Vertex)];
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 // Copy the data back
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 memcpy (m_data, copy, oldSize);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 delete[] copy;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73 const VertexCompiler::Vertex* VertexCompiler::Array::data() const
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 return m_data;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
80 const VertexCompiler::Array::Size& VertexCompiler::Array::allocatedSize() const
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
81 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82 return m_size;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
84
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 VertexCompiler::Array::Size VertexCompiler::Array::writtenSize() const
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 return (m_ptr - m_data) * sizeof (Vertex);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
92 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94 void VertexCompiler::Array::write (const Vertex& f)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 // Ensure there's enoughspace for the new vertex
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 resizeToFit (writtenSize() + sizeof f);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99 // Write the float in
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100 *m_ptr++ = f;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
105 void VertexCompiler::Array::merge (Array* other)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
106 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
107 // Ensure there's room for both buffers
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
108 resizeToFit (writtenSize() + other->writtenSize());
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
109
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110 memcpy (m_ptr, other->data(), other->writtenSize());
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111 m_ptr += other->writtenSize() / sizeof (Vertex);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
116 VertexCompiler::VertexCompiler() :
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117 m_file (null)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
118 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119 needMerge();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 VertexCompiler::~VertexCompiler() {}
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125 // Note: we use the top level object's color but the draw object's vertices.
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126 // This is so that the index color is generated correctly - it has to reference
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
127 // the top level object's ID. This is crucial for picking to work.
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129 void VertexCompiler::compilePolygon (LDObject* drawobj, LDObject* trueobj, QList< VertexCompiler::CompiledTriangle >& data)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131 const QColor pickColor = getObjectColor (trueobj, PickColor);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 LDObject::Type type = drawobj->getType();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133 LDObjectList objs;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
134
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
135 assert (type != LDObject::ESubfile);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137 if (type == LDObject::EQuad)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139 for (LDTriangle * t : static_cast<LDQuad*> (drawobj)->splitToTriangles())
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
140 objs << t;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
141 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 else
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143 objs << drawobj;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145 for (LDObject* obj : objs)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147 const LDObject::Type objtype = obj->getType();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
148 const bool isline = (objtype == LDObject::ELine || objtype == LDObject::ECondLine);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
149 const int verts = isline ? 2 : obj->vertices();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
150 QColor normalColor = getObjectColor (obj, Normal);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152 assert (isline || objtype == LDObject::ETriangle);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
153
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
154 CompiledTriangle a;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
155 a.rgb = normalColor.rgb();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
156 a.pickrgb = pickColor.rgb();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157 a.numVerts = verts;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
158 a.obj = trueobj;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
159 a.isCondLine = (objtype == LDObject::ECondLine);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
160
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
161 for (int i = 0; i < verts; ++i)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
162 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
163 a.verts[i] = obj->getVertex (i);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
164 a.verts[i].y() = -a.verts[i].y();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165 a.verts[i].z() = -a.verts[i].z();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
166 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
167
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168 data << a;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
169 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
170 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
171
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
172 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
173 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
174 void VertexCompiler::compileObject (LDObject* obj)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
175 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176 initObject (obj);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
177 QList<CompiledTriangle> data;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
178 QTime t0;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
179
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
180 for (int i = 0; i < GL::NumArrays; ++i)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181 m_objArrays[obj][i].clear();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
182
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
183 t0 = QTime::currentTime();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
184 compileSubObject (obj, obj, data);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
185 DEBUG_PRINT ("COMPILATION: %1ms\n", t0.msecsTo (QTime::currentTime()));
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
187 t0 = QTime::currentTime();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
188
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
189 for (int i = 0; i < GL::NumArrays; ++i)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
190 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
191 GL::VAOType type = (GL::VAOType) i;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
192 const bool islinearray = (type == GL::EdgeArray || type == GL::EdgePickArray);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
193
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
194 for (const CompiledTriangle & poly : data)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
195 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
196 if (poly.isCondLine)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
197 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
198 // Conditional lines go to the edge pick array and the array
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
199 // specifically designated for conditional lines and nowhere else.
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
200 if (type != GL::EdgePickArray && type != GL::CondEdgeArray)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201 continue;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
202 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
203 else
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
204 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
205 // Lines and only lines go to the line array and only to the line array.
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
206 if ( (poly.numVerts == 2) ^ islinearray)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207 continue;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
208
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
209 // Only conditional lines go into the conditional line array
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
210 if (type == GL::CondEdgeArray)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211 continue;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
212 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
213
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
214 Array* verts = postprocess (poly, type);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
215 m_objArrays[obj][type].merge (verts);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
216 delete verts;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
217 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
218 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
219
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
220 DEBUG_PRINT ("POST-PROCESS: %1ms\n", t0.msecsTo (QTime::currentTime()));
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
221
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
222 needMerge();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
223 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
224
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
225 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
226 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
227 void VertexCompiler::compileSubObject (LDObject* obj, LDObject* topobj, QList< VertexCompiler::CompiledTriangle >& data)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
228 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
229 LDObjectList objs;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
230
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
231 switch (obj->getType())
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
232 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
233 case LDObject::ETriangle:
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
234 case LDObject::ELine:
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
235 case LDObject::ECondLine:
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
236 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
237 compilePolygon (obj, topobj, data);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
238 } break;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
239
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
240 case LDObject::EQuad:
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
241 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
242 for (LDTriangle * triangle : static_cast<LDQuad*> (obj)->splitToTriangles())
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
243 compilePolygon (triangle, topobj, data);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
244 } break;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
245
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
246 case LDObject::ESubfile:
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
247 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
248 QTime t0 = QTime::currentTime();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
249 objs = static_cast<LDSubfile*> (obj)->inlineContents (LDSubfile::RendererInline | LDSubfile::DeepCacheInline);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
250 DEBUG_PRINT ("\t- INLINE: %1ms\n", t0.msecsTo (QTime::currentTime()));
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
251 DEBUG_PRINT ("\t- %1 objects\n", objs.size());
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
252
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
253 t0 = QTime::currentTime();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
254
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
255 for (LDObject* obj : objs)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
256 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
257 compileSubObject (obj, topobj, data);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
258 obj->deleteSelf();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
259 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
260
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
261 DEBUG_PRINT ("\t- SUB-COMPILATION: %1ms\n", t0.msecsTo (QTime::currentTime()));
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
262 } break;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
263
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
264 default:
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
265 {} break;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
266 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
267 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
268
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
269 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
270 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
271 void VertexCompiler::compileDocument()
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
272 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
273 for (LDObject * obj : m_file->getObjects())
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
274 compileObject (obj);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
275 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
276
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
277 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
278 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
279 void VertexCompiler::forgetObject (LDObject* obj)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
280 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
281 auto it = m_objArrays.find (obj);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
282
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
283 if (it != m_objArrays.end())
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
284 delete *it;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
285
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
286 m_objArrays.remove (obj);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
287 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
288
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
289 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
290 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
291 void VertexCompiler::setFile (LDDocument* file)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
292 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
293 m_file = file;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
294 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
295
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
296 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
297 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
298 const VertexCompiler::Array* VertexCompiler::getMergedBuffer (GL::VAOType type)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
299 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
300 // If there are objects staged for compilation, compile them now.
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
301 if (m_staged.size() > 0)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
302 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
303 for (LDObject * obj : m_staged)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
304 compileObject (obj);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
305
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
306 m_staged.clear();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
307 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
308
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
309 assert (type < GL::NumArrays);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
310
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
311 if (m_changed[type])
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
312 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
313 m_changed[type] = false;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
314 m_mainArrays[type].clear();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
315
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
316 for (LDObject* obj : m_file->getObjects())
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
317 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
318 if (!obj->isScemantic())
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
319 continue;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
320
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
321 auto it = m_objArrays.find (obj);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
322
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
323 if (it != m_objArrays.end())
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
324 m_mainArrays[type].merge (& (*it) [type]);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
325 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
326
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
327 DEBUG_PRINT ("merged array %1: %2 bytes\n", (int) type, m_mainArrays[type].writtenSize());
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
328 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
329
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
330 return &m_mainArrays[type];
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
331 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
332
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
333 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
334 // This turns a compiled triangle into usable VAO vertices
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
335 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
336 VertexCompiler::Array* VertexCompiler::postprocess (const CompiledTriangle& triangle, GL::VAOType type)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
337 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
338 Array* va = new Array;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
339 QList<Vertex> verts;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
340
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
341 for (int i = 0; i < triangle.numVerts; ++i)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
342 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
343 alias v0 = triangle.verts[i];
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
344 Vertex v;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
345 v.x = v0.x();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
346 v.y = v0.y();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
347 v.z = v0.z();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
348
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
349 switch (type)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
350 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
351 case GL::MainArray:
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
352 case GL::EdgeArray:
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
353 case GL::CondEdgeArray:
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
354 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
355 v.color = triangle.rgb;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
356 } break;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
357
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
358 case GL::PickArray:
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
359 case GL::EdgePickArray:
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
360 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
361 v.color = triangle.pickrgb;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
362 } break;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
363
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
364 case GL::BFCArray:
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
365 case GL::NumArrays:
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
366 break; // handled separately
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
367 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
368
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
369 verts << v;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
370 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
371
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
372 if (type == GL::BFCArray)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
373 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
374 int32 rgb = getObjectColor (triangle.obj, BFCFront).rgb();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
375
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
376 for (Vertex v : verts)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
377 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
378 v.color = rgb;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
379 va->write (v);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
380 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
381
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
382 rgb = getObjectColor (triangle.obj, BFCBack).rgb();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
383
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
384 for (int i = verts.size() - 1; i >= 0; --i)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
385 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
386 Vertex v = verts[i];
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
387 v.color = rgb;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
388 va->write (v);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
389 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
390 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
391 else
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
392 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
393 for (Vertex v : verts)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
394 va->write (v);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
395 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
396
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
397 return va;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
398 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
399
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
400 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
401 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
402 uint32 VertexCompiler::getColorRGB (QColor& color)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
403 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
404 return
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
405 (color.red() & 0xFF) << 0x00 |
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
406 (color.green() & 0xFF) << 0x08 |
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
407 (color.blue() & 0xFF) << 0x10 |
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
408 (color.alpha() & 0xFF) << 0x18;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
409 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
410
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
411 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
412 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
413 QColor VertexCompiler::getObjectColor (LDObject* obj, ColorType colotype) const
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
414 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
415 QColor qcol;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
416
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
417 if (!obj->isColored())
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
418 return QColor();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
419
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
420 if (colotype == PickColor)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
421 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
422 // Make the color by the object's ID if we're picking, so we can make the
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
423 // ID again from the color we get from the picking results. Be sure to use
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
424 // the top level parent's index since we want a subfile's children point
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
425 // to the subfile itself.
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
426 long i = obj->topLevelParent()->getID();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
427
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
428 // Calculate a color based from this index. This method caters for
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
429 // 16777216 objects. I don't think that'll be exceeded anytime soon. :)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
430 // ATM biggest is 53588.dat with 12600 lines.
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
431 int r = (i / (256 * 256)) % 256,
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
432 g = (i / 256) % 256,
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
433 b = i % 256;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
434
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
435 return QColor (r, g, b);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
436 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
437
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
438 if ( (colotype == BFCFront || colotype == BFCBack) &&
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
439 obj->getType() != LDObject::ELine &&
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
440 obj->getType() != LDObject::ECondLine
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
441 )
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
442 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
443 if (colotype == BFCFront)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
444 qcol = QColor (40, 192, 0);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
445 else
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
446 qcol = QColor (224, 0, 0);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
447 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
448 else
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
449 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
450 if (obj->getColor() == maincolor)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
451 qcol = GL::getMainColor();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
452 else
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
453 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
454 LDColor* col = getColor (obj->getColor());
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
455
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
456 if (col)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
457 qcol = col->faceColor;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
458 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
459
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
460 if (obj->getColor() == edgecolor)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
461 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
462 qcol = QColor (32, 32, 32); // luma (m_bgcolor) < 40 ? QColor (64, 64, 64) : Qt::black;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
463 LDColor* col;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
464
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
465 if (!gl_blackedges && obj->getParent() && (col = getColor (obj->getParent()->getColor())))
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
466 qcol = col->edgeColor;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
467 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
468
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
469 if (qcol.isValid() == false)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
470 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
471 // The color was unknown. Use main color to make the object at least
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
472 // not appear pitch-black.
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
473 if (obj->getColor() != edgecolor)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
474 qcol = GL::getMainColor();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
475 else
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
476 qcol = Qt::black;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
477
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
478 // Warn about the unknown color, but only once.
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
479 for (short i : g_warnedColors)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
480 if (obj->getColor() == i)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
481 return qcol;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
482
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
483 log ("%1: Unknown color %2!\n", __func__, obj->getColor());
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
484 g_warnedColors << obj->getColor();
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
485 return qcol;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
486 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
487 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
488
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
489 if (obj->topLevelParent()->isSelected())
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
490 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
491 // Brighten it up if selected.
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
492 const int add = 51;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
493
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
494 qcol.setRed (min (qcol.red() + add, 255));
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
495 qcol.setGreen (min (qcol.green() + add, 255));
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
496 qcol.setBlue (min (qcol.blue() + add, 255));
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
497 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
498
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
499 return qcol;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
500 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
501
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
502 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
503 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
504 void VertexCompiler::needMerge()
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
505 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
506 // Set all of m_changed to true
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
507 memset (m_changed, 0xFF, sizeof m_changed);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
508 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
509
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
510 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
511 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
512 void VertexCompiler::initObject (LDObject* obj)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
513 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
514 if (m_objArrays.find (obj) == m_objArrays.end())
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
515 m_objArrays[obj] = new Array[GL::NumArrays];
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
516 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
517
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
518 // =============================================================================
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
519 // -----------------------------------------------------------------------------
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
520 void VertexCompiler::stageForCompilation (LDObject* obj)
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
521 {
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
522 m_staged << obj;
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
523 removeDuplicates (m_staged);
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
524 }
6a05c4969074 - now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
525

mercurial