Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
Unterteilungsalgorithmen
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kai Westerkamp
Unterteilungsalgorithmen
Commits
1c1d13b3
Commit
1c1d13b3
authored
Jul 21, 2016
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use shared_ptr for SubdivEntrys
parent
5493df80
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
+11
-7
mesh.cpp
QTProject/mesh.cpp
+6
-5
mesh.h
QTProject/mesh.h
+2
-1
subdivision.cpp
QTProject/subdivision.cpp
+3
-1
No files found.
QTProject/mesh.cpp
View file @
1c1d13b3
...
@@ -86,7 +86,8 @@ void Mesh::MeshEntry::init(QOpenGLFunctions_4_3_Core *f,QVector<Vertex>& Vertice
...
@@ -86,7 +86,8 @@ void Mesh::MeshEntry::init(QOpenGLFunctions_4_3_Core *f,QVector<Vertex>& Vertice
this
->
f
=
f
;
this
->
f
=
f
;
buffers
.
resize
(
1
);
buffers
.
resize
(
1
);
buffers
[
0
].
init
(
f
,
Vertices
,
Indices
);
buffers
[
0
].
reset
(
new
SubdivEntry
);
buffers
[
0
]
->
init
(
f
,
Vertices
,
Indices
);
//calc AABB
//calc AABB
for
(
int
i
=
0
;
i
<
Vertices
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
Vertices
.
size
();
++
i
)
{
...
@@ -102,8 +103,8 @@ void Mesh::MeshEntry::init(QOpenGLFunctions_4_3_Core *f,QVector<Vertex>& Vertice
...
@@ -102,8 +103,8 @@ void Mesh::MeshEntry::init(QOpenGLFunctions_4_3_Core *f,QVector<Vertex>& Vertice
}
}
void
Mesh
::
MeshEntry
::
update
(
GLuint
VB
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices
){
void
Mesh
::
MeshEntry
::
update
(
GLuint
VB
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices
){
buffers
.
resize
(
buffers
.
size
()
+
1
)
;
SubdivEntry
*
entry
=
new
SubdivEntry
;
SubdivEntry
*
entry
=
&
buffers
[
buffers
.
size
()
-
1
]
;
buffers
.
push_back
(
std
::
shared_ptr
<
SubdivEntry
>
(
entry
))
;
entry
->
init
(
f
,
VB
,
Vertices
,
Indices
);
entry
->
init
(
f
,
VB
,
Vertices
,
Indices
);
}
}
...
@@ -461,11 +462,11 @@ void Mesh::renderMesh(QOpenGLShaderProgram *shader, int index, int subdivision,
...
@@ -461,11 +462,11 @@ void Mesh::renderMesh(QOpenGLShaderProgram *shader, int index, int subdivision,
materials
[
MaterialIndex
].
texture
.
bind
(
f
,
GL_TEXTURE0
);
materials
[
MaterialIndex
].
texture
.
bind
(
f
,
GL_TEXTURE0
);
}
}
if
(
entries
[
index
].
buffers
.
size
()
<=
subdivision
){
if
(
entries
[
index
].
buffers
.
size
()
<=
subdivision
){
subdivision
=
entries
[
index
].
buffers
.
size
()
-
1
;
subdivision
=
entries
[
index
].
buffers
.
size
()
-
1
;
}
}
SubdivEntry
*
entry
=
&
entries
[
index
].
buffers
[
subdivision
];
std
::
shared_ptr
<
SubdivEntry
>
entry
=
entries
[
index
].
buffers
[
subdivision
];
// Draw Vertex Array
// Draw Vertex Array
f
->
glBindBuffer
(
GL_ARRAY_BUFFER
,
entry
->
VB_handle
);
f
->
glBindBuffer
(
GL_ARRAY_BUFFER
,
entry
->
VB_handle
);
...
...
QTProject/mesh.h
View file @
1c1d13b3
#ifndef MESH_H
#ifndef MESH_H
#define MESH_H
#define MESH_H
#include <memory>
#include <QtOpenGL>
#include <QtOpenGL>
#include <QOpenGLFunctions_4_3_Core>
#include <QOpenGLFunctions_4_3_Core>
#include <assimp/Importer.hpp>
#include <assimp/Importer.hpp>
...
@@ -89,7 +90,7 @@ public:
...
@@ -89,7 +90,7 @@ public:
QString
name
;
QString
name
;
QVector
<
SubdivEntry
>
buffers
;
QVector
<
std
::
shared_ptr
<
SubdivEntry
>
>
buffers
;
int
materialIndex
;
int
materialIndex
;
...
...
QTProject/subdivision.cpp
View file @
1c1d13b3
#include <memory>
#include "subdivision.h"
#include "subdivision.h"
Subdivision
::
Subdivision
(
QOpenGLFunctions_4_3_Core
*
f
)
Subdivision
::
Subdivision
(
QOpenGLFunctions_4_3_Core
*
f
)
...
@@ -63,7 +65,7 @@ void Subdivision::subdivide(Mesh *mesh, int level) {
...
@@ -63,7 +65,7 @@ void Subdivision::subdivide(Mesh *mesh, int level) {
if
(
level
<=
currentMax
)
if
(
level
<=
currentMax
)
return
;
return
;
Mesh
::
SubdivEntry
*
entry
=
&
current_mesh
->
buffers
[
currentMax
];
std
::
shared_ptr
<
Mesh
::
SubdivEntry
>
entry
=
current_mesh
->
buffers
[
currentMax
];
input
.
vb_handle
=
entry
->
VB_handle
;
input
.
vb_handle
=
entry
->
VB_handle
;
input
.
vertex_buffer
=
entry
->
vertices
;
input
.
vertex_buffer
=
entry
->
vertices
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment