src/gl/partrenderer.h

Sun, 09 Apr 2023 16:01:57 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sun, 09 Apr 2023 16:01:57 +0300
changeset 364
39fbdee0c0c8
parent 360
41b38b9e05a2
child 372
b2914aaeec1a
permissions
-rw-r--r--

I forgot to add files again... this time it's modelsubwindow.h

17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #pragma once
264
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 237
diff changeset
2 #include "src/basics.h"
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 237
diff changeset
3 #include "src/documentmanager.h"
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 237
diff changeset
4 #include "src/types/boundingbox.h"
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 237
diff changeset
5 #include "src/gl/common.h"
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 237
diff changeset
6 #include "src/gl/compiler.h"
291
42b4953dff85 Let's bring GLEW back after all
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
7 #include <QOpenGLWidget>
17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8
217
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
9 class PartRenderer final : public QOpenGLWidget
17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 {
21
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
11 Q_OBJECT
338
719b909a7d2b Delete unused code
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 333
diff changeset
12 QTextDocument* const model;
217
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
13 DocumentManager* const documents;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
14 const ColorTable& colorTable;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
15 BoundingBox boundingBox;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
16 gl::ModelShaders shaders;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
17 ModelId highlighted = {0};
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
18 glm::mat4 projectionMatrix;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
19 glm::mat4 viewMatrix;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
20 glm::mat4 modelMatrix;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
21 glm::vec4 viewportVector;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
22 glm::quat modelQuaternion;
359
73b6c478378e The renderer now centers on the grid origin, not the part origin
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 338
diff changeset
23 glm::vec3 modelViewOrigin = {0, 0, 0};
217
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
24 QPoint lastMousePosition;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
25 int totalMouseMove = 0;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
26 gl::RenderPreferences renderPreferences;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
27 double zoom = 1.0;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
28 bool initialized = false;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
29 bool needBuild = true;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
30 std::vector<RenderLayer*> activeRenderLayers;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
31 std::vector<RenderLayer*> inactiveRenderLayers;
313
c24d87f64bed Improve click handling
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
32 std::chrono::time_point<std::chrono::steady_clock> lastClickTime;
232
8efa3a33172e Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 217
diff changeset
33 bool frozen = false;
17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
34 public:
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 34
diff changeset
35 PartRenderer(
338
719b909a7d2b Delete unused code
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 333
diff changeset
36 QTextDocument* model,
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 34
diff changeset
37 DocumentManager* documents,
205
1a4342d80de7 Refactor colors.cpp/.h
Teemu Piippo <teemu@hecknology.net>
parents: 201
diff changeset
38 const ColorTable& colorTable,
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 34
diff changeset
39 QWidget* parent = nullptr);
26
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 22
diff changeset
40 ~PartRenderer() override;
39
caac957e9834 Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents: 37
diff changeset
41 void setRenderPreferences(const gl::RenderPreferences& newPreferences);
200
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 199
diff changeset
42 ModelId getHighlightedObject() const;
215
34c6e7bc4ee1 Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 206
diff changeset
43 void addRenderLayer(RenderLayer* layer);
34c6e7bc4ee1 Reimplement the axes program as a layer that can be added to PartRenderer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 206
diff changeset
44 void setLayerEnabled(RenderLayer* layer, bool enabled);
217
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
45 std::optional<glm::vec3> screenToModelCoordinates(const QPointF& point, const Plane& plane) const;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
46 QPointF modelToScreenCoordinates(const glm::vec3& point) const;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
47 bool isDark() const;
333
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 322
diff changeset
48 std::int32_t pick(QPoint where);
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 322
diff changeset
49 void setSelection(const QSet<std::int32_t>& selectedIds);
313
c24d87f64bed Improve click handling
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
50 glm::vec3 cameraVector(const QPointF& point) const;
c24d87f64bed Improve click handling
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 309
diff changeset
51 Line<3> cameraLine(const QPointF& point) const;
359
73b6c478378e The renderer now centers on the grid origin, not the part origin
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 338
diff changeset
52 Q_SLOT void setModelViewOrigin(const glm::vec3& newViewOrigin);
112
5760cbb32bc0 use QT_NO_KEYWORDS
Teemu Piippo <teemu@hecknology.net>
parents: 107
diff changeset
53 Q_SIGNALS:
70
f21b800b02a4 Added axes rendering
Teemu Piippo <teemu@hecknology.net>
parents: 66
diff changeset
54 void projectionMatrixChanged(const glm::mat4& newMatrix);
f21b800b02a4 Added axes rendering
Teemu Piippo <teemu@hecknology.net>
parents: 66
diff changeset
55 void modelMatrixChanged(const glm::mat4& newMatrix);
f21b800b02a4 Added axes rendering
Teemu Piippo <teemu@hecknology.net>
parents: 66
diff changeset
56 void viewMatrixChanged(const glm::mat4& newMatrix);
61
4585d8d7a7ec moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents: 58
diff changeset
57 void renderPreferencesChanged();
237
10a6298f636f Add an option to log opengl messages
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 232
diff changeset
58 void message(const Message& message);
17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
59 private:
217
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
60 void initializeGL() override;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
61 void resizeGL(int width, int height) override;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
62 void paintGL() override;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
63 void mouseMoveEvent(QMouseEvent* event) override;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
64 void mousePressEvent(QMouseEvent* event) override;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
65 void mouseReleaseEvent(QMouseEvent* event) override;
232
8efa3a33172e Add base code for circular primitives
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 217
diff changeset
66 void keyReleaseEvent(QKeyEvent* event) override;
217
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
67 void wheelEvent(QWheelEvent* event) override;
6d95c1a41e6e reimplement EditTools as a render layer
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 215
diff changeset
68 glm::vec3 unproject(const glm::vec3& win) const;
37
90443fb328ea wired renderstyle up
Teemu Piippo <teemu@hecknology.net>
parents: 36
diff changeset
69 void setFragmentStyle(gl::FragmentStyle fragStyle);
22
6da867fa5429 commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
70 void renderScene();
31
b6df269a2c6b fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents: 30
diff changeset
71 void updateViewMatrix();
55
cb81ecb5fb23 grid stuff
Teemu Piippo <teemu@hecknology.net>
parents: 53
diff changeset
72 void updateModelMatrix();
86
4bec0525ef1b PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents: 73
diff changeset
73 Q_SLOT void build();
360
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
74 void renderVao(const gl::ArrayClass arrayClass, const GLenum glType);
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
75 template<gl::ArrayClass arrayClass>
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
76 void renderVao();
26
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 22
diff changeset
77 void checkForGLErrors();
17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
78 };
322
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
79
360
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
80 inline constexpr opt<GLenum> getGlTypeForArrayClass(const gl::ArrayClass vboClass)
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
81 {
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
82 switch (vboClass)
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
83 {
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
84 case gl::ArrayClass::Lines:
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
85 case gl::ArrayClass::ConditionalLines:
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
86 return GL_LINES;
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
87 case gl::ArrayClass::Triangles:
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
88 return GL_TRIANGLES;
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
89 case gl::ArrayClass::Quads:
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
90 return GL_QUADS;
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
91 }
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
92 return {};
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
93 }
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
94
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
95 template<gl::ArrayClass arrayClass>
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
96 void PartRenderer::renderVao()
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
97 {
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
98 constexpr opt<GLenum> glType = getGlTypeForArrayClass(arrayClass);
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
99 static_assert(glType.has_value());
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
100 this->renderVao(arrayClass, *glType);
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
101 }
41b38b9e05a2 `PartRenderer::renderVao` no longer throws if bad array class is given, this is now checked on compile time
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 359
diff changeset
102
322
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
103 inline QVector<QPointF> convertWorldPointsToScreenPoints(
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
104 const std::vector<glm::vec3> &worldPoints,
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
105 const PartRenderer* renderer)
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
106 {
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
107 QVector<QPointF> points2d;
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
108 points2d.reserve(static_cast<int>(worldPoints.size()));
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
109 for (const glm::vec3& point : worldPoints)
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
110 {
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
111 points2d.push_back(renderer->modelToScreenCoordinates(point));
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
112 }
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
113 return points2d;
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
114 }
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
115
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
116 inline Winding worldPolygonWinding(
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
117 const std::vector<glm::vec3> &points,
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
118 const PartRenderer* renderer)
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
119 {
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
120 return winding(QPolygonF{convertWorldPointsToScreenPoints(points, renderer)});
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
121 }
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
122
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
123 inline void drawWorldPoint(
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
124 QPainter* painter,
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
125 const glm::vec3& worldPoint,
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
126 const PartRenderer* renderer)
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
127 {
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
128 const QPointF center = renderer->modelToScreenCoordinates(worldPoint);
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
129 painter->drawEllipse(inscribe(CircleF{center, 5}));
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
130 }
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
131
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
132 inline void drawWorldPolyline(
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
133 QPainter *painter,
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
134 const std::vector<glm::vec3> &points,
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
135 const PartRenderer* renderer)
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
136 {
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
137 painter->drawPolyline(QPolygonF{convertWorldPointsToScreenPoints(points, renderer)});
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
138 }
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
139
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
140 inline void drawWorldPolygon(
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
141 QPainter* painter,
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
142 const std::vector<glm::vec3> &points,
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
143 const PartRenderer* renderer)
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
144 {
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
145 painter->drawPolygon(QPolygonF{convertWorldPointsToScreenPoints(points, renderer)});
a39f454a3d7f Reduce edittools.cpp further
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 313
diff changeset
146 }

mercurial