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
fc9a48c7
Commit
fc9a48c7
authored
Sep 01, 2016
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'patchRender' of…
Merge branch 'patchRender' of
ssh://git.breab.org:2223/kai/Unterteilungsalgorithmen
into patchRender
parents
d4fae3f2
9ead25f6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
19 deletions
+35
-19
subdivision.cpp
QTProject/subdivision.cpp
+31
-16
subdivision.h
QTProject/subdivision.h
+4
-3
No files found.
QTProject/subdivision.cpp
View file @
fc9a48c7
...
@@ -65,9 +65,10 @@ void Subdivision::subdivide(Mesh *mesh, int level) {
...
@@ -65,9 +65,10 @@ void Subdivision::subdivide(Mesh *mesh, int level) {
input
.
vb_handle
=
entry
->
VB_handle
;
input
.
vb_handle
=
entry
->
VB_handle
;
input
.
vertex_buffer
=
entry
->
vertices
;
input
.
vertex_buffer
=
entry
->
vertices
;
input
.
index_buffer
=
entry
->
indices_irregular
;
input
.
index_irregular_buffer
=
entry
->
indices_irregular
;
input
.
index_regular_buffer
=
getTriangles
(
entry
->
indices_regular
);
if
(
input
.
index_buffer
.
isEmpty
())
{
if
(
input
.
index_
irregular_
buffer
.
isEmpty
())
{
// current_mesh->update(input.vb_handle, input.vertex_buffer, input.index_buffer, entry->indices_regular);
// current_mesh->update(input.vb_handle, input.vertex_buffer, input.index_buffer, entry->indices_regular);
}
else
{
}
else
{
Tables
tables
=
precomputeTables
(
input
);
Tables
tables
=
precomputeTables
(
input
);
...
@@ -137,8 +138,11 @@ struct Edge {
...
@@ -137,8 +138,11 @@ struct Edge {
Subdivision
::
Tables
Subdivision
::
precomputeTables
(
Input
input
)
{
Subdivision
::
Tables
Subdivision
::
precomputeTables
(
Input
input
)
{
Tables
tables
;
Tables
tables
;
QVector
<
unsigned
int
>
ib
=
input
.
index_buffer
;
QVector
<
unsigned
int
>
ib
=
input
.
index_irregular_buffer
;
qCDebug
(
log_subdiv_trace
)
<<
"Index Buffer: "
<<
ib
;
qCDebug
(
log_subdiv_trace
)
<<
"Index Buffer Irregular: "
<<
ib
;
QVector
<
unsigned
int
>
ib_regular
=
input
.
index_regular_buffer
;
qCDebug
(
log_subdiv_trace
)
<<
"Index Buffer Regular: "
<<
ib_regular
;
QVector
<
Vertex
>
vb
=
input
.
vertex_buffer
;
QVector
<
Vertex
>
vb
=
input
.
vertex_buffer
;
qCDebug
(
log_subdiv_trace
)
<<
"Vertex Buffer: "
<<
vb
;
qCDebug
(
log_subdiv_trace
)
<<
"Vertex Buffer: "
<<
vb
;
...
@@ -147,16 +151,20 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
...
@@ -147,16 +151,20 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
for
(
int
i
=
0
;
i
<
ib
.
length
();
i
+=
3
)
{
for
(
int
i
=
0
;
i
<
ib
.
length
();
i
+=
3
)
{
triangles
.
push_back
(
Triangle
(
vb
,
ib
[
i
],
ib
[
i
+
1
],
ib
[
i
+
2
]));
triangles
.
push_back
(
Triangle
(
vb
,
ib
[
i
],
ib
[
i
+
1
],
ib
[
i
+
2
]));
}
}
QVector
<
Triangle
>
triangles_regular
;
for
(
int
i
=
0
;
i
<
ib_regular
.
length
();
i
+=
3
)
{
triangles
.
push_back
(
Triangle
(
vb
,
ib_regular
[
i
],
ib_regular
[
i
+
1
],
ib_regular
[
i
+
2
]));
}
precomputeEdgeTable
(
tables
,
triangles
,
(
unsigned
int
)
vb
.
length
());
precomputeEdgeTable
(
tables
,
triangles
,
triangles_regular
,
(
unsigned
int
)
vb
.
length
());
precomputeVertexTable
(
tables
,
vb
,
ib
);
precomputeVertexTable
(
tables
,
vb
,
ib
,
ib_regular
);
//tables.patch_index_regular = getPatchIndexBuffer(ib, QVector<unsigned int>());//TODO pass regular and irregular index buffer?
//tables.patch_index_regular = getPatchIndexBuffer(ib, QVector<unsigned int>());//TODO pass regular and irregular index buffer?
qCDebug
(
log_subdiv
)
<<
"Precompute Tables Done"
;
qCDebug
(
log_subdiv
)
<<
"Precompute Tables Done"
;
return
tables
;
return
tables
;
}
}
void
Subdivision
::
precomputeEdgeTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Triangle
>
&
triangles
,
unsigned
int
offset
)
{
void
Subdivision
::
precomputeEdgeTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Triangle
>
&
triangles
,
QVector
<
Triangle
>
&
triangles_regular
,
unsigned
int
offset
)
{
//compute edge table
//compute edge table
//Format: first two entries: edge vertices. last two entries: distant vertices.
//Format: first two entries: edge vertices. last two entries: distant vertices.
...
@@ -188,6 +196,12 @@ void Subdivision::precomputeEdgeTable(Subdivision::Tables &tables, QVector<Trian
...
@@ -188,6 +196,12 @@ void Subdivision::precomputeEdgeTable(Subdivision::Tables &tables, QVector<Trian
insert_edge
(
opposite_edges
,
triangles
[
j
],
edge_b
,
edge_a
);
insert_edge
(
opposite_edges
,
triangles
[
j
],
edge_b
,
edge_a
);
}
}
}
}
for
(
int
j
=
0
;
j
<
triangles_regular
.
length
();
j
++
){
if
(
triangle
.
get_shared_edge
(
triangles_regular
[
j
],
edge_a
,
edge_b
))
{
insert_edge
(
opposite_edges
,
triangle
,
edge_a
,
edge_b
);
// no need to insert the opposite edge of a regular triangle - it won't be processed by the outer loop
}
}
QVector
<
Triangle
::
Edge
>
opposite
=
opposite_edges
.
value
(
triangle
);
QVector
<
Triangle
::
Edge
>
opposite
=
opposite_edges
.
value
(
triangle
);
...
@@ -272,10 +286,11 @@ void Subdivision::precomputeEdgeTable(Subdivision::Tables &tables, QVector<Trian
...
@@ -272,10 +286,11 @@ void Subdivision::precomputeEdgeTable(Subdivision::Tables &tables, QVector<Trian
}
}
}
}
void
Subdivision
::
precomputeVertexTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Vertex
>
&
vb
,
QVector
<
unsigned
int
>
&
ib
)
{
void
Subdivision
::
precomputeVertexTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Vertex
>
&
vb
,
QVector
<
unsigned
int
>
&
ib
,
QVector
<
unsigned
int
>
&
ib_regular
)
{
//compute vertex table
//compute vertex table
//Format: First entry: original vertex. Other entries: adjacent vertices.
//Format: First entry: original vertex. Other entries: adjacent vertices.
QVector
<
QVector
<
unsigned
int
>
>
duplicates
;
//for debugging
QVector
<
QVector
<
unsigned
int
>
>
duplicates
;
//for debugging
QVector
<
unsigned
int
>
ib_combined
=
ib
+
ib_regular
;
unsigned
int
offset
=
0
;
unsigned
int
offset
=
0
;
for
(
int
i
=
0
;
i
<
vb
.
length
();
i
++
){
for
(
int
i
=
0
;
i
<
vb
.
length
();
i
++
){
//hat evtl viel redundanz
//hat evtl viel redundanz
...
@@ -289,21 +304,21 @@ void Subdivision::precomputeVertexTable(Subdivision::Tables &tables, QVector<Ver
...
@@ -289,21 +304,21 @@ void Subdivision::precomputeVertexTable(Subdivision::Tables &tables, QVector<Ver
QVector
<
unsigned
int
>
d
;
QVector
<
unsigned
int
>
d
;
for
(
int
j
=
0
;
j
<
ib
.
length
();
j
++
){
for
(
int
j
=
0
;
j
<
ib
_combined
.
length
();
j
++
){
//suche verweise auf vertex im indexbuffer
//suche verweise auf vertex im indexbuffer
if
(
vb
[
ib
[
j
]].
samePos
(
originalVertex
)){
if
(
vb
[
ib
_combined
[
j
]].
samePos
(
originalVertex
)){
d
.
push_back
(
j
);
d
.
push_back
(
j
);
unsigned
int
i1
,
i2
;
//indices for neighbour vertices
unsigned
int
i1
,
i2
;
//indices for neighbour vertices
if
(
j
%
3
==
0
){
if
(
j
%
3
==
0
){
i1
=
ib
[
j
+
1
];
i1
=
ib
_combined
[
j
+
1
];
i2
=
ib
[
j
+
2
];
i2
=
ib
_combined
[
j
+
2
];
}
else
if
(
j
%
3
==
1
){
}
else
if
(
j
%
3
==
1
){
i1
=
ib
[
j
-
1
];
i1
=
ib
_combined
[
j
-
1
];
i2
=
ib
[
j
+
1
];
i2
=
ib
_combined
[
j
+
1
];
}
else
{
}
else
{
i1
=
ib
[
j
-
2
];
i1
=
ib
_combined
[
j
-
2
];
i2
=
ib
[
j
-
1
];
i2
=
ib
_combined
[
j
-
1
];
}
}
Vertex
v1
,
v2
;
//neighbour vertices;
Vertex
v1
,
v2
;
//neighbour vertices;
...
...
QTProject/subdivision.h
View file @
fc9a48c7
...
@@ -22,7 +22,8 @@ private:
...
@@ -22,7 +22,8 @@ private:
struct
Input
struct
Input
{
{
GLuint
vb_handle
;
GLuint
vb_handle
;
QVector
<
unsigned
int
>
index_buffer
;
QVector
<
unsigned
int
>
index_irregular_buffer
;
QVector
<
unsigned
int
>
index_regular_buffer
;
QVector
<
Vertex
>
vertex_buffer
;
QVector
<
Vertex
>
vertex_buffer
;
};
};
...
@@ -53,8 +54,8 @@ private:
...
@@ -53,8 +54,8 @@ private:
QOpenGLShaderProgram
*
initComputeShaderProgram
(
QString
&
source
);
QOpenGLShaderProgram
*
initComputeShaderProgram
(
QString
&
source
);
Tables
precomputeTables
(
Input
input
);
Tables
precomputeTables
(
Input
input
);
void
precomputeEdgeTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Triangle
>
&
triangles
,
unsigned
int
offset
);
void
precomputeEdgeTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Triangle
>
&
triangles
,
QVector
<
Triangle
>
&
triangles_regular
,
unsigned
int
offset
);
void
precomputeVertexTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Vertex
>
&
vb
,
QVector
<
unsigned
int
>
&
ib
);
void
precomputeVertexTable
(
Subdivision
::
Tables
&
tables
,
QVector
<
Vertex
>
&
vb
,
QVector
<
unsigned
int
>
&
ib
,
QVector
<
unsigned
int
>
&
ib_regular
);
void
findRegular
(
QVector
<
unsigned
int
>
index_buffer
,
QVector
<
Vertex
>
vertex_buffer
,
QVector
<
unsigned
int
>
&
regular
,
QVector
<
unsigned
int
>
&
irregular
);
void
findRegular
(
QVector
<
unsigned
int
>
index_buffer
,
QVector
<
Vertex
>
vertex_buffer
,
QVector
<
unsigned
int
>
&
regular
,
QVector
<
unsigned
int
>
&
irregular
);
Result
runShader
(
Input
input
,
Tables
&
tables
);
Result
runShader
(
Input
input
,
Tables
&
tables
);
void
runVertexShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
vertex_indices_handle
,
GLuint
vertex_offsets_handle
,
GLuint
output_handle
);
void
runVertexShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
vertex_indices_handle
,
GLuint
vertex_offsets_handle
,
GLuint
output_handle
);
...
...
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