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
9349f665
Commit
9349f665
authored
Sep 27, 2016
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '14-benutze-neighbors-map-in-precomputevertextable' into 'patchRender'
Resolve "Benutze neighbors map in precomputeVertexTable" Closes
#14
See merge request
!11
parents
25fccdc3
6883649b
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
8 deletions
+32
-8
mesh.cpp
QTProject/mesh.cpp
+21
-4
mesh.h
QTProject/mesh.h
+5
-2
subdivision.cpp
QTProject/subdivision.cpp
+0
-0
subdivision.h
QTProject/subdivision.h
+6
-2
No files found.
QTProject/mesh.cpp
View file @
9349f665
...
@@ -40,22 +40,24 @@ void Mesh::SubdivEntry::init(QOpenGLFunctions_4_3_Core *f,QVector<Vertex>& Verti
...
@@ -40,22 +40,24 @@ void Mesh::SubdivEntry::init(QOpenGLFunctions_4_3_Core *f,QVector<Vertex>& Verti
f
->
glBufferData
(
GL_ARRAY_BUFFER
,
sizeof
(
Vertex
)
*
Vertices
.
size
(),
&
Vertices
[
0
],
GL_STATIC_DRAW
);
f
->
glBufferData
(
GL_ARRAY_BUFFER
,
sizeof
(
Vertex
)
*
Vertices
.
size
(),
&
Vertices
[
0
],
GL_STATIC_DRAW
);
QVector
<
unsigned
int
>
patches
;
QVector
<
unsigned
int
>
patches
;
this
->
init
(
f
,
VB_handle
,
Vertices
,
Vertices
,
Indices_irregular
,
patches
);
this
->
init
(
f
,
VB_handle
,
Vertices
,
Vertices
,
Indices_irregular
,
patches
,
patches
);
}
}
void
Mesh
::
SubdivEntry
::
init
(
QOpenGLFunctions_4_3_Core
*
f
,
GLuint
VB_handle
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
Vertex
>&
Vertices_irregular
,
void
Mesh
::
SubdivEntry
::
init
(
QOpenGLFunctions_4_3_Core
*
f
,
GLuint
VB_handle
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
Vertex
>&
Vertices_irregular
,
QVector
<
unsigned
int
>&
Indices_irregular
,
QVector
<
unsigned
int
>&
patches
){
QVector
<
unsigned
int
>&
Indices_irregular
,
QVector
<
unsigned
int
>&
patches
,
QVector
<
unsigned
int
>&
Indices_extra
){
this
->
f
=
f
;
this
->
f
=
f
;
this
->
VB_handle
=
VB_handle
;
this
->
VB_handle
=
VB_handle
;
vertices
=
Vertices
;
vertices
=
Vertices
;
indices_irregular
=
Indices_irregular
;
indices_irregular
=
Indices_irregular
;
indices_regular
=
patches
;
indices_regular
=
patches
;
indices_extra
=
Indices_extra
;
qCDebug
(
log_mesh
)
<<
"Vertices"
<<
vertices
.
length
();
qCDebug
(
log_mesh
)
<<
"Vertices"
<<
vertices
.
length
();
qCDebug
(
log_mesh
)
<<
"Vertices Irregular"
<<
Vertices_irregular
.
length
();
qCDebug
(
log_mesh
)
<<
"Vertices Irregular"
<<
Vertices_irregular
.
length
();
qCDebug
(
log_mesh
)
<<
"Indices irregular"
<<
indices_irregular
.
length
();
qCDebug
(
log_mesh
)
<<
"Indices irregular"
<<
indices_irregular
.
length
();
qCDebug
(
log_mesh
)
<<
"Indices patches"
<<
patches
.
length
();
qCDebug
(
log_mesh
)
<<
"Indices patches"
<<
patches
.
length
();
qCDebug
(
log_mesh
)
<<
"Indices extra"
<<
Indices_extra
.
length
();
f
->
glGenBuffers
(
1
,
&
VB_handle_irregular
);
f
->
glGenBuffers
(
1
,
&
VB_handle_irregular
);
f
->
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
VB_handle_irregular
);
f
->
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
VB_handle_irregular
);
...
@@ -71,6 +73,11 @@ void Mesh::SubdivEntry::init(QOpenGLFunctions_4_3_Core *f, GLuint VB_handle, QVe
...
@@ -71,6 +73,11 @@ void Mesh::SubdivEntry::init(QOpenGLFunctions_4_3_Core *f, GLuint VB_handle, QVe
f
->
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
IB_regular_handle
);
f
->
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
IB_regular_handle
);
if
(
patches
.
size
()
!=
0
)
if
(
patches
.
size
()
!=
0
)
f
->
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
sizeof
(
unsigned
int
)
*
patches
.
size
(),
&
patches
[
0
],
GL_STATIC_DRAW
);
f
->
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
sizeof
(
unsigned
int
)
*
patches
.
size
(),
&
patches
[
0
],
GL_STATIC_DRAW
);
f
->
glGenBuffers
(
1
,
&
IB_extra_handle
);
f
->
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
IB_extra_handle
);
if
(
Indices_extra
.
size
()
!=
0
)
f
->
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
sizeof
(
unsigned
int
)
*
Indices_extra
.
size
(),
&
Indices_extra
[
0
],
GL_STATIC_DRAW
);
}
}
...
@@ -103,10 +110,10 @@ void Mesh::MeshEntry::init(QOpenGLFunctions_4_3_Core *f,QVector<Vertex>& Vertice
...
@@ -103,10 +110,10 @@ void Mesh::MeshEntry::init(QOpenGLFunctions_4_3_Core *f,QVector<Vertex>& Vertice
}
}
}
}
void
Mesh
::
MeshEntry
::
update
(
GLuint
VB_handle
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
Vertex
>&
Vertices_Irregular
,
QVector
<
unsigned
int
>&
Indices_irregular
,
QVector
<
unsigned
int
>&
patches
)
{
void
Mesh
::
MeshEntry
::
update
(
GLuint
VB_handle
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
Vertex
>&
Vertices_Irregular
,
QVector
<
unsigned
int
>&
Indices_irregular
,
QVector
<
unsigned
int
>&
patches
,
QVector
<
unsigned
int
>&
Indices_extra
)
{
SubdivEntry
*
entry
=
new
SubdivEntry
;
SubdivEntry
*
entry
=
new
SubdivEntry
;
buffers
.
push_back
(
std
::
shared_ptr
<
SubdivEntry
>
(
entry
));
buffers
.
push_back
(
std
::
shared_ptr
<
SubdivEntry
>
(
entry
));
entry
->
init
(
f
,
VB_handle
,
Vertices
,
Vertices_Irregular
,
Indices_irregular
,
patches
);
entry
->
init
(
f
,
VB_handle
,
Vertices
,
Vertices_Irregular
,
Indices_irregular
,
patches
,
Indices_extra
);
}
}
Mesh
::
MeshEntry
::~
MeshEntry
()
Mesh
::
MeshEntry
::~
MeshEntry
()
...
@@ -495,6 +502,16 @@ void Mesh::renderMesh(QOpenGLShaderProgram *shader, int index, int subdivision,
...
@@ -495,6 +502,16 @@ void Mesh::renderMesh(QOpenGLShaderProgram *shader, int index, int subdivision,
f
->
glPatchParameteri
(
GL_PATCH_VERTICES
,
3
);
f
->
glPatchParameteri
(
GL_PATCH_VERTICES
,
3
);
f
->
glDrawElements
(
GL_PATCHES
,
entry
->
indices_irregular
.
size
(),
GL_UNSIGNED_INT
,
0
);
f
->
glDrawElements
(
GL_PATCHES
,
entry
->
indices_irregular
.
size
(),
GL_UNSIGNED_INT
,
0
);
}
}
if
(
!
entry
->
indices_extra
.
isEmpty
()
&&
false
)
{
shader
->
setUniformValue
(
"materialInfo.Diffuse"
,
QVector3D
(
0.0
,
156.0
,
18.0
)
/
255.0
);
f
->
glBindBuffer
(
GL_ARRAY_BUFFER
,
entry
->
VB_handle
);
f
->
glVertexAttribPointer
(
positionIndex
,
3
,
GL_FLOAT
,
GL_FALSE
,
sizeof
(
Vertex
),
0
);
f
->
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
entry
->
IB_extra_handle
);
f
->
glPatchParameteri
(
GL_PATCH_VERTICES
,
3
);
f
->
glDrawElements
(
GL_PATCHES
,
entry
->
indices_extra
.
size
(),
GL_UNSIGNED_INT
,
0
);
}
}
}
}
}
...
...
QTProject/mesh.h
View file @
9349f665
...
@@ -34,20 +34,23 @@ public:
...
@@ -34,20 +34,23 @@ public:
GLuint
VB_handle
;
GLuint
VB_handle
;
GLuint
VB_handle_irregular
;
GLuint
VB_handle_irregular
;
GLuint
IB_irregular_handle
;
GLuint
IB_irregular_handle
;
GLuint
IB_regular_handle
;
GLuint
IB_regular_handle
;
GLuint
IB_extra_handle
;
QVector
<
Vertex
>
vertices
;
QVector
<
Vertex
>
vertices
;
QVector
<
Vertex
>
vertices_irregular
;
QVector
<
Vertex
>
vertices_irregular
;
QVector
<
unsigned
int
>
indices_irregular
;
QVector
<
unsigned
int
>
indices_irregular
;
QVector
<
unsigned
int
>
indices_regular
;
QVector
<
unsigned
int
>
indices_regular
;
QVector
<
unsigned
int
>
indices_extra
;
QOpenGLFunctions_4_3_Core
*
f
;
QOpenGLFunctions_4_3_Core
*
f
;
void
init
(
QOpenGLFunctions_4_3_Core
*
f
,
QVector
<
Vertex
>&
Vertices
,
void
init
(
QOpenGLFunctions_4_3_Core
*
f
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices_irregular
);
QVector
<
unsigned
int
>&
Indices_irregular
);
void
init
(
QOpenGLFunctions_4_3_Core
*
f
,
GLuint
VB_handle
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
Vertex
>&
Vertices_irregular
,
void
init
(
QOpenGLFunctions_4_3_Core
*
f
,
GLuint
VB_handle
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
Vertex
>&
Vertices_irregular
,
QVector
<
unsigned
int
>&
Indices_irregular
,
QVector
<
unsigned
int
>&
patches
);
QVector
<
unsigned
int
>&
Indices_irregular
,
QVector
<
unsigned
int
>&
patches
,
QVector
<
unsigned
int
>&
Indices_extra
);
void
updateIndices
();
void
updateIndices
();
};
};
...
@@ -56,7 +59,7 @@ public:
...
@@ -56,7 +59,7 @@ public:
~
MeshEntry
();
~
MeshEntry
();
void
init
(
QOpenGLFunctions_4_3_Core
*
f
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices
);
void
init
(
QOpenGLFunctions_4_3_Core
*
f
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
unsigned
int
>&
Indices
);
void
update
(
GLuint
VB_handle
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
Vertex
>&
Vertices_Irregular
,
QVector
<
unsigned
int
>&
Indices_irregular
,
QVector
<
unsigned
int
>&
patches
);
void
update
(
GLuint
VB_handle
,
QVector
<
Vertex
>&
Vertices
,
QVector
<
Vertex
>&
Vertices_Irregular
,
QVector
<
unsigned
int
>&
Indices_irregular
,
QVector
<
unsigned
int
>&
patches
,
QVector
<
unsigned
int
>&
Indices_extra
);
QString
name
;
QString
name
;
...
...
QTProject/subdivision.cpp
View file @
9349f665
This diff is collapsed.
Click to expand it.
QTProject/subdivision.h
View file @
9349f665
...
@@ -62,8 +62,11 @@ private:
...
@@ -62,8 +62,11 @@ private:
Tables
precomputeTables
(
Input
input
);
Tables
precomputeTables
(
Input
input
);
void
buildNeighborsMap
(
QVector
<
Vertex
>
&
vb
,
QVector
<
Triangle
>
&
triangles
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
&
neighbors
);
void
buildNeighborsMap
(
QVector
<
Vertex
>
&
vb
,
QVector
<
Triangle
>
&
triangles
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
&
neighbors
);
QVector
<
Triangle
>
vertexNeighbors
(
Triangle
&
triangle
,
Triangle
::
Neighbor
current_neighbor
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
neighbors
);
QVector
<
Triangle
>
vertexNeighbors
(
Triangle
&
triangle
,
Triangle
::
Neighbor
current_neighbor
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
neighbors
);
void
precomputeEdgeTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Triangle
>
&
triangles
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
&
neighbors
,
unsigned
int
offset
);
void
precomputeEdgeTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Triangle
>
&
triangles
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
&
neighbors
,
unsigned
int
offset
,
QVector
<
Triangle
>
extra_old_triangles
);
void
precomputeVertexTable
(
Subdivision
::
Tables
&
tables
,
Input
&
input
,
QMap
<
unsigned
int
,
unsigned
int
>
&
modified_vertices
);
void
precomputeVertexTable
(
Tables
&
tables
,
QVector
<
Vertex
>
&
vb
,
QVector
<
Triangle
>
&
irregular_triangles
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
neighbors
,
QMap
<
unsigned
int
,
unsigned
int
>
&
modified_vertices
);
bool
containsVertexIndex
(
const
QVector
<
Vertex
>
&
vb
,
const
QVector
<
unsigned
int
>
&
vertices
,
const
Vertex
vertex
)
const
;
QVector
<
unsigned
int
>
getAllVertexIndices
(
const
QVector
<
Vertex
>
&
vb
,
const
QVector
<
Triangle
>
&
triangles
);
bool
removeVertexIndex
(
const
QVector
<
Vertex
>
&
vb
,
QVector
<
unsigned
int
>
&
vertices
,
const
Vertex
&
vertex
);
void
updateIndexBuffer
(
QVector
<
unsigned
int
>
&
index_buffer
,
QMap
<
unsigned
int
,
unsigned
int
>
map
);
void
updateIndexBuffer
(
QVector
<
unsigned
int
>
&
index_buffer
,
QMap
<
unsigned
int
,
unsigned
int
>
map
);
void
findRegular
(
QVector
<
Triangle
>
triangles
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
neighbors
,
QVector
<
Triangle
>
&
regular
,
QVector
<
Triangle
>
&
irregular
);
void
findRegular
(
QVector
<
Triangle
>
triangles
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
neighbors
,
QVector
<
Triangle
>
&
regular
,
QVector
<
Triangle
>
&
irregular
);
Result
runShader
(
Input
input
,
Tables
&
tables
);
Result
runShader
(
Input
input
,
Tables
&
tables
);
...
@@ -72,6 +75,7 @@ private:
...
@@ -72,6 +75,7 @@ private:
void
runEdgeShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
edge_indices_handle
,
GLuint
output_handle
,
GLuint
offset_handle
);
void
runEdgeShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
edge_indices_handle
,
GLuint
output_handle
,
GLuint
offset_handle
);
void
updateIrregularForDraw
(
const
QVector
<
Triangle
>
&
triangles
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
&
neighbors
,
Result
&
result
);
void
updateIrregularForDraw
(
const
QVector
<
Triangle
>
&
triangles
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
&
neighbors
,
Result
&
result
);
bool
containsVertex
(
QVector
<
Vertex
>
&
vertices
,
Vertex
vertex
);
bool
containsVertex
(
QVector
<
Vertex
>
&
vertices
,
Vertex
vertex
);
QVector
<
Vertex
>
getAllVertices
(
const
QVector
<
Triangle
>
&
triangles
);
QVector3D
updateIrregularVertexForDraw
(
Vertex
currentCorner
,
QVector
<
Triangle
>
neighboring_triangles
);
QVector3D
updateIrregularVertexForDraw
(
Vertex
currentCorner
,
QVector
<
Triangle
>
neighboring_triangles
);
QVector
<
unsigned
int
>
patchIBToTriangleIB
(
QVector
<
unsigned
int
>
ib
);
QVector
<
unsigned
int
>
patchIBToTriangleIB
(
QVector
<
unsigned
int
>
ib
);
...
...
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