src/GLCompiler.cc

Tue, 21 Jan 2014 02:09:14 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Tue, 21 Jan 2014 02:09:14 +0200
changeset 675
450827da2376
parent 674
3d8ab0f89102
child 676
f7f965742fd5
permissions
-rw-r--r--

Merge ../ldforge into gl

Conflicts:
src/GLRenderer.cc
src/GLRenderer.h
src/LDObject.cc

672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 #include "GLCompiler.h"
675
450827da2376 Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 674
diff changeset
2 #include "LDObject.h"
450827da2376 Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 674
diff changeset
3 #include "Colors.h"
450827da2376 Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 674
diff changeset
4 #include "Document.h"
450827da2376 Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 674
diff changeset
5 #include "Misc.h"
450827da2376 Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents: 674
diff changeset
6 #include "GLRenderer.h"
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 #include <QDate>
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
9 #define DE_BUG_PRINT(...) fprint (stdout, __VA_ARGS__)
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 extern_cfg (Bool, gl_blackedges);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 static QList<short> g_warnedColors;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 GLCompiler g_vertexCompiler;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 // =============================================================================
673
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
16 //
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 GLCompiler::GLCompiler() :
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18 m_file (null)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 needMerge();
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 GLCompiler::~GLCompiler() {}
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 // =============================================================================
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 // Note: we use the top level object's color but the draw object's vertices.
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 // This is so that the index color is generated correctly - it has to reference
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 // the top level object's ID. This is crucial for picking to work.
673
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
29 //
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 void GLCompiler::compilePolygon (LDObject* drawobj, LDObject* trueobj, QList< GLCompiler::CompiledTriangle >& data)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 {
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
32 const QColor pickColor = getObjectColor (trueobj, E_PickColor);
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 LDObject::Type type = drawobj->getType();
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 LDObjectList objs;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 assert (type != LDObject::ESubfile);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 if (type == LDObject::EQuad)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 for (LDTriangle* t : static_cast<LDQuad*> (drawobj)->splitToTriangles())
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 objs << t;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 else
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 objs << drawobj;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 for (LDObject* obj : objs)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 const LDObject::Type objtype = obj->getType();
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 const bool isline = (objtype == LDObject::ELine || objtype == LDObject::ECondLine);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 const int verts = isline ? 2 : obj->vertices();
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
51 QColor normalColor = getObjectColor (obj, E_NormalColor);
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 assert (isline || objtype == LDObject::ETriangle);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 CompiledTriangle a;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 a.rgb = getColorRGB (normalColor);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 a.pickrgb = getColorRGB (pickColor);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 a.numVerts = verts;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 a.obj = trueobj;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 a.isCondLine = (objtype == LDObject::ECondLine);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 for (int i = 0; i < verts; ++i)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 a.verts[i] = obj->getVertex (i);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 a.verts[i].y() = -a.verts[i].y();
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 a.verts[i].z() = -a.verts[i].z();
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 data << a;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73 // =============================================================================
673
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
74 //
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 void GLCompiler::compileObject (LDObject* obj)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77 initObject (obj);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 QList<CompiledTriangle> data;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 QTime t0;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
80
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
81 t0 = QTime::currentTime();
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
82 for (int i = 0; i < E_NumVertexArrays; ++i)
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 m_objArrays[obj][i].clear();
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
84 DE_BUG_PRINT ("INIT: %1ms\n", t0.msecsTo (QTime::currentTime()));
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 t0 = QTime::currentTime();
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 compileSubObject (obj, obj, data);
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
88 DE_BUG_PRINT ("COMPILATION: %1ms\n", t0.msecsTo (QTime::currentTime()));
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90 t0 = QTime::currentTime();
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
92 for (int i = 0; i < E_NumVertexArrays; ++i)
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 {
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
94 E_VertexArrayType type = (E_VertexArrayType) i;
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
95 const bool islinearray = (type == E_EdgeArray || type == E_EdgePickArray);
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 for (const CompiledTriangle& poly : data)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99 if (poly.isCondLine)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101 // Conditional lines go to the edge pick array and the array
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 // specifically designated for conditional lines and nowhere else.
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
103 // They are kept separate from the regular edge array so that
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
104 // they can be drawn as dashed lines.
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
105 //
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
106 // However we don't need nor desire that behavior for the pick
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
107 // scene, so they can be grouped with normal edgelines for that.
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
108 if (type != E_EdgePickArray && type != E_CondEdgeArray)
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
109 continue;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111 else
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112 {
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
113 // Lines and only lines go to line arrays and only to line arrays.
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
114 if ((poly.numVerts == 2) ^ islinearray)
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115 continue;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
116
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117 // Only conditional lines go into the conditional line array
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
118 if (type == E_CondEdgeArray)
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119 continue;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
122 // Postprocess the polygon into a VAO and add it in
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
123 VertexArray* verts = postprocess (poly, type);
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124 m_objArrays[obj][type] += *verts;
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
125
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
126 // The array is changed, it needs a merge now.
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
127 m_changed[type] = true;
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128 delete verts;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
132 DE_BUG_PRINT ("POST-PROCE_SS: %1ms\n", t0.msecsTo (QTime::currentTime()));
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
134
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
135 // =============================================================================
673
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
136 //
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137 void GLCompiler::compileSubObject (LDObject* obj, LDObject* topobj, GLCompiler::PolygonList& data)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139 LDObjectList objs;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
140
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
141 switch (obj->getType())
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143 case LDObject::ETriangle:
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 case LDObject::ELine:
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145 case LDObject::ECondLine:
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147 compilePolygon (obj, topobj, data);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
148 } break;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
149
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
150 case LDObject::EQuad:
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152 QTime t0 = QTime::currentTime();
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
153 for (LDTriangle* triangle : static_cast<LDQuad*> (obj)->splitToTriangles())
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
154 compilePolygon (triangle, topobj, data);
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
155 DE_BUG_PRINT ("\t- QUAD COMPILE: %1ms\n", t0.msecsTo (QTime::currentTime()));
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
156 } break;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
158 case LDObject::ESubfile:
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
159 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
160 QTime t0 = QTime::currentTime();
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
161 objs = static_cast<LDSubfile*> (obj)->inlineContents (LDSubfile::RendererInline | LDSubfile::DeepCacheInline);
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
162 DE_BUG_PRINT ("\t- INLINE: %1ms\n", t0.msecsTo (QTime::currentTime()));
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
163 DE_BUG_PRINT ("\t- %1 objects\n", objs.size());
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
164
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165 t0 = QTime::currentTime();
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
166
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
167 for (LDObject* obj : objs)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
169 compileSubObject (obj, topobj, data);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
170 obj->deleteSelf();
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
171 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
172
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
173 DE_BUG_PRINT ("\t- SUB-COMPILATION: %1ms\n", t0.msecsTo (QTime::currentTime()));
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
174 } break;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
175
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176 default:
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
177 {} break;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
178 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
179 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
180
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181 // =============================================================================
673
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
182 //
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
183 void GLCompiler::compileDocument()
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
184 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
185 for (LDObject * obj : m_file->getObjects())
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186 compileObject (obj);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
187 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
188
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
189 // =============================================================================
673
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
190 //
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
191 void GLCompiler::forgetObject (LDObject* obj)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
192 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
193 auto it = m_objArrays.find (obj);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
194
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
195 if (it != m_objArrays.end())
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
196 delete *it;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
197
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
198 m_objArrays.remove (obj);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
199 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
200
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201 // =============================================================================
673
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
202 //
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
203 void GLCompiler::setFile (LDDocument* file)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
204 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
205 m_file = file;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
206 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
208 // =============================================================================
673
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
209 //
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
210 const GLCompiler::VertexArray* GLCompiler::getMergedBuffer (E_VertexArrayType type)
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
212 // If there are objects staged for compilation, compile them now.
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
213 if (m_staged.size() > 0)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
214 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
215 for (LDObject * obj : m_staged)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
216 compileObject (obj);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
217
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
218 m_staged.clear();
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
219 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
220
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
221 assert (type < E_NumVertexArrays);
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
222
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
223 if (m_changed[type])
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
224 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
225 m_changed[type] = false;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
226 m_mainArrays[type].clear();
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
227
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
228 for (LDObject* obj : m_file->getObjects())
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
229 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
230 if (!obj->isScemantic())
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
231 continue;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
232
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
233 auto it = m_objArrays.find (obj);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
234
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
235 if (it != m_objArrays.end())
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
236 m_mainArrays[type] += (*it)[type];
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
237 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
238
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
239 DE_BUG_PRINT ("merged array %1: %2 entries\n", (int) type, m_mainArrays[type].size());
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
240 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
241
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
242 return &m_mainArrays[type];
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
243 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
244
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
245 // =============================================================================
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
246 // This turns a compiled triangle into usable VAO vertices
673
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
247 //
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
248 GLCompiler::VertexArray* GLCompiler::postprocess (const CompiledTriangle& poly, E_VertexArrayType type)
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
249 {
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
250 VertexArray* va = new VertexArray;
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
251 VertexArray verts;
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
252
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
253 for (int i = 0; i < poly.numVerts; ++i)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
254 {
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
255 VAO vao;
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
256 const auto& v0 = poly.verts[i];
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
257 vao.x = v0.x();
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
258 vao.y = v0.y();
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
259 vao.z = v0.z();
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
260
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
261 switch (type)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
262 {
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
263 case E_SurfaceArray:
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
264 case E_EdgeArray:
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
265 case E_CondEdgeArray:
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
266 {
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
267 vao.color = poly.rgb;
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
268 } break;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
269
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
270 case E_PickArray:
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
271 case E_EdgePickArray:
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
272 {
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
273 vao.color = poly.pickrgb;
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
274 } break;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
275
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
276 case E_BFCArray:
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
277 case E_NumVertexArrays:
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
278 break;
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
279 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
280
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
281 verts << vao;
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
282 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
283
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
284 if (type == E_BFCArray)
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
285 {
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
286 int32 rgb = getColorRGB (getObjectColor (poly.obj, E_BFCFrontColor));
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
287
673
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
288 for (VAO vao : verts)
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
289 {
673
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
290 vao.color = rgb;
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
291 *va << vao;
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
292 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
293
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
294 rgb = getColorRGB (getObjectColor (poly.obj, E_BFCBackColor));
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
295
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
296 for (int i = verts.size() - 1; i >= 0; --i)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
297 {
673
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
298 VAO vao = verts[i];
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
299 vao.color = rgb;
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
300 *va << vao;
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
301 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
302 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
303 else
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
304 *va = verts;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
305
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
306 return va;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
307 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
308
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
309 // =============================================================================
673
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
310 //
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
311 uint32 GLCompiler::getColorRGB (const QColor& color)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
312 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
313 return
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
314 (color.red() & 0xFF) << 0x00 |
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
315 (color.green() & 0xFF) << 0x08 |
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
316 (color.blue() & 0xFF) << 0x10 |
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
317 (color.alpha() & 0xFF) << 0x18;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
318 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
319
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
320 // =============================================================================
673
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
321 //
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
322 QColor GLCompiler::getObjectColor (LDObject* obj, GLCompiler::E_ColorType colortype) const
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
323 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
324 QColor qcol;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
325
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
326 if (!obj->isColored())
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
327 return QColor();
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
328
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
329 if (colortype == E_PickColor)
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
330 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
331 // Make the color by the object's ID if we're picking, so we can make the
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
332 // ID again from the color we get from the picking results. Be sure to use
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
333 // the top level parent's index since we want a subfile's children point
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
334 // to the subfile itself.
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
335 long i = obj->topLevelParent()->getID();
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
336
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
337 // Calculate a color based from this index. This method caters for
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
338 // 16777216 objects. I don't think that'll be exceeded anytime soon. :)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
339 // ATM biggest is 53588.dat with 12600 lines.
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
340 int r = (i / 0x10000) % 0x100,
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
341 g = (i / 0x100) % 0x100,
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
342 b = i % 0x100;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
343
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
344 return QColor (r, g, b);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
345 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
346
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
347 if ((colortype == E_BFCFrontColor || colortype == E_BFCBackColor) &&
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
348 obj->getType() != LDObject::ELine &&
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
349 obj->getType() != LDObject::ECondLine)
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
350 {
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
351 if (colortype == E_BFCFrontColor)
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
352 qcol = QColor (40, 192, 0);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
353 else
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
354 qcol = QColor (224, 0, 0);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
355 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
356 else
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
357 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
358 if (obj->getColor() == maincolor)
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
359 qcol = GLRenderer::getMainColor();
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
360 else
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
361 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
362 LDColor* col = getColor (obj->getColor());
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
363
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
364 if (col)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
365 qcol = col->faceColor;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
366 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
367
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
368 if (obj->getColor() == edgecolor)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
369 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
370 qcol = QColor (32, 32, 32); // luma (m_bgcolor) < 40 ? QColor (64, 64, 64) : Qt::black;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
371 LDColor* col;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
372
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
373 if (!gl_blackedges && obj->getParent() && (col = getColor (obj->getParent()->getColor())))
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
374 qcol = col->edgeColor;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
375 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
376
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
377 if (qcol.isValid() == false)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
378 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
379 // The color was unknown. Use main color to make the object at least
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
380 // not appear pitch-black.
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
381 if (obj->getColor() != edgecolor)
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
382 qcol = GLRenderer::getMainColor();
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
383 else
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
384 qcol = Qt::black;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
385
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
386 // Warn about the unknown color, but only once.
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
387 for (short i : g_warnedColors)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
388 if (obj->getColor() == i)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
389 return qcol;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
390
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
391 log ("%1: Unknown color %2!\n", __func__, obj->getColor());
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
392 g_warnedColors << obj->getColor();
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
393 return qcol;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
394 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
395 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
396
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
397 if (obj->topLevelParent()->isSelected())
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
398 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
399 // Brighten it up if selected.
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
400 const int add = 51;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
401
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
402 qcol.setRed (min (qcol.red() + add, 255));
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
403 qcol.setGreen (min (qcol.green() + add, 255));
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
404 qcol.setBlue (min (qcol.blue() + add, 255));
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
405 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
406
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
407 return qcol;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
408 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
409
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
410 // =============================================================================
673
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
411 //
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
412 void GLCompiler::needMerge()
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
413 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
414 // Set all of m_changed to true
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
415 memset (m_changed, 0xFF, sizeof m_changed);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
416 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
417
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
418 // =============================================================================
673
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
419 //
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
420 void GLCompiler::initObject (LDObject* obj)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
421 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
422 if (m_objArrays.find (obj) == m_objArrays.end())
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 673
diff changeset
423 m_objArrays[obj] = new VertexArray[E_NumVertexArrays];
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
424 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
425
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
426 // =============================================================================
673
8e6f5b3f9d38 - rename GLCompiler::Vertex to GLCompiler::VAO to avoid name conflicts
Santeri Piippo <crimsondusk64@gmail.com>
parents: 672
diff changeset
427 //
672
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
428 void GLCompiler::stageForCompilation (LDObject* obj)
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
429 {
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
430 m_staged << obj;
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
431 removeDuplicates (m_staged);
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
432 }
0925d25ea32c - renamed VertexCompiler to GLCompiler
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
433

mercurial