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
23085e12
Commit
23085e12
authored
Jun 28, 2016
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Input struct
This will make it easier to iterate over all meshes in subdivide when we want to add that feature.
parent
97ea391e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
38 deletions
+31
-38
subdivision.cpp
QTProject/subdivision.cpp
+22
-36
subdivision.h
QTProject/subdivision.h
+9
-2
No files found.
QTProject/subdivision.cpp
View file @
23085e12
...
...
@@ -46,33 +46,33 @@ QOpenGLShaderProgram *Subdivision::initComputeShaderProgram(QString &source){
}
Mesh
*
Subdivision
::
subdivide
(
Mesh
*
mesh
)
{
// For now we only look at the first mesh entry
Mesh
::
Node
root
=
mesh
->
getRootNode
();
int
first_mesh_index
=
-
1
;
if
(
!
root
.
getFirstMeshIndex
(
first_mesh_index
))
{
qCritical
()
<<
"No mesh found, aborting subdivision"
;
return
NULL
;
}
Mesh
::
MeshEntry
*
current_mesh
=
mesh
->
getMeshEntry
(
first_mesh_index
);
Input
input
;
input
.
vb_handle
=
current_mesh
->
VB_handle
;
input
.
vertex_buffer
=
current_mesh
->
getVertexBuffer
();
input
.
index_buffer
=
current_mesh
->
getIndexBuffer
();
QVector
<
QVector
<
unsigned
int
>
>
edgeIndices
;
QVector
<
unsigned
int
>
vertexIndices
;
QVector
<
unsigned
int
>
vertexIndicesOffsets
;
precomputeTables
(
mesh
,
edgeIndices
,
vertexIndices
,
vertexIndicesOffsets
);
runShader
(
mesh
,
edgeIndices
);
precomputeTables
(
input
,
edgeIndices
,
vertexIndices
,
vertexIndicesOffsets
);
runShader
(
input
,
edgeIndices
);
return
NULL
;
}
void
Subdivision
::
precomputeTables
(
Mesh
*
mesh
,
QVector
<
QVector
<
unsigned
int
>
>
&
edgeIndices_base
,
void
Subdivision
::
precomputeTables
(
Input
input
,
QVector
<
QVector
<
unsigned
int
>
>
&
edgeIndices_base
,
QVector
<
unsigned
int
>
&
vertexIndices
,
QVector
<
unsigned
int
>
&
vertexIndicesOffsets
)
{
Mesh
::
Node
root
=
mesh
->
getRootNode
();
int
firstMeshEntryIndex
=
-
1
;
bool
meshExists
=
root
.
getFirstMeshIndex
(
firstMeshEntryIndex
);
if
(
!
meshExists
){
qDebug
()
<<
"No Mesh found. Abort subdiv table precomputation."
;
return
;
}
qDebug
()
<<
"Mesh found. Index:"
<<
firstMeshEntryIndex
;
//die drei zeilen machen das bild schwarz. wenn man davor returnt tuts.
Mesh
::
MeshEntry
*
firstMeshEntry
=
mesh
->
getMeshEntry
(
firstMeshEntryIndex
);
QVector
<
unsigned
int
>
ib
=
firstMeshEntry
->
getIndexBuffer
();
qDebug
()
<<
"Index Buffer: "
<<
ib
;
QVector
<
Vertex
>
vb
=
firstMeshEntry
->
getVertexBuffer
();
//qDebug()<<"Vertex Buffer: "<<vb;
QVector
<
unsigned
int
>
ib
=
input
.
index_buffer
;
QVector
<
Vertex
>
vb
=
input
.
vertex_buffer
;
//compute edge table
//Format: first two entries: edge vertices. last two entries: distant vertices.
...
...
@@ -264,25 +264,11 @@ void Subdivision::precomputeTables(Mesh *mesh, QVector<QVector<unsigned int> > &
}
void
Subdivision
::
runShader
(
Mesh
*
mesh
,
QVector
<
QVector
<
unsigned
int
>
>
&
edgeIndices
)
{
void
Subdivision
::
runShader
(
Input
input
,
QVector
<
QVector
<
unsigned
int
>
>
&
edgeIndices
)
{
qDebug
()
<<
"Running compute shader"
;
Mesh
::
Node
root
=
mesh
->
getRootNode
();
int
firstMeshEntryIndex
=
-
1
;
bool
meshExists
=
root
.
getFirstMeshIndex
(
firstMeshEntryIndex
);
if
(
!
meshExists
){
qDebug
()
<<
"No Mesh found. Abort shader execution."
;
return
;
}
qDebug
()
<<
"Mesh found. Index:"
<<
firstMeshEntryIndex
;
Mesh
::
MeshEntry
*
firstMeshEntry
=
mesh
->
getMeshEntry
(
firstMeshEntryIndex
);
GLuint
vb_handle
=
firstMeshEntry
->
VB_handle
;
QVector
<
Vertex
>
vb
=
firstMeshEntry
->
getVertexBuffer
();
edgeShader
->
bind
();
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
0
,
vb_handle
);
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
0
,
input
.
vb_handle
);
GLuint
*
edgeIDs
=
new
GLuint
[
edgeIndices
.
size
()
*
4
];
for
(
uint
i
=
0
;
i
<
edgeIndices
.
size
();
i
++
)
{
...
...
QTProject/subdivision.h
View file @
23085e12
...
...
@@ -16,13 +16,20 @@ public:
Mesh
*
subdivide
(
Mesh
*
mesh
);
private
:
struct
Input
{
GLuint
vb_handle
;
QVector
<
unsigned
int
>
index_buffer
;
QVector
<
Vertex
>
vertex_buffer
;
};
QOpenGLFunctions_4_3_Core
*
f
;
QOpenGLShaderProgram
*
edgeShader
;
QOpenGLShaderProgram
*
initComputeShaderProgram
(
QString
&
source
);
void
precomputeTables
(
Mesh
*
mesh
,
QVector
<
QVector
<
unsigned
int
>
>
&
edgeIndices_base
,
void
precomputeTables
(
Input
input
,
QVector
<
QVector
<
unsigned
int
>
>
&
edgeIndices_base
,
QVector
<
unsigned
int
>
&
vertexIndices
,
QVector
<
unsigned
int
>
&
vertexIndicesOffsets
);
void
runShader
(
Mesh
*
mesh
,
QVector
<
QVector
<
unsigned
int
>
>
&
edgeIndices
);
void
runShader
(
Input
input
,
QVector
<
QVector
<
unsigned
int
>
>
&
edgeIndices
);
QVector
<
unsigned
int
>
fillVector
(
unsigned
int
a
,
unsigned
int
b
,
unsigned
int
c
,
unsigned
int
d
);
};
...
...
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