Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Niflib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Grant Kim
Niflib
Commits
ab284331
Commit
ab284331
authored
13 years ago
by
Amorilia
Browse files
Options
Downloads
Patches
Plain Diff
Fixed match group calculation (contributed by Ethatron).
parent
96902779
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/obj/NiTriShapeData.cpp
+43
-7
43 additions, 7 deletions
src/obj/NiTriShapeData.cpp
with
43 additions
and
7 deletions
src/obj/NiTriShapeData.cpp
+
43
−
7
View file @
ab284331
...
...
@@ -200,15 +200,51 @@ void NiTriShapeData::SetVertices( const vector<Vector3> & in ) {
matchGroups
.
clear
();
}
void
NiTriShapeData
::
DoMatchDetection
()
{
matchGroups
.
resize
(
vertices
.
size
()
);
void
NiTriShapeData
::
DoMatchDetection
()
{
/* minimum number of groups of shared normals */
matchGroups
.
resize
(
0
);
/* counting sharing */
vector
<
int
>
sharing
(
vertices
.
size
(),
0
);
for
(
unsigned
int
i
=
0
;
i
<
vertices
.
size
()
-
1
;
++
i
)
{
/* this index belongs to a group already */
if
(
sharing
[
i
]
!=
0
)
continue
;
/* we may find a valid group for this vertex */
MatchGroup
group
;
for
(
unsigned
int
i
=
0
;
i
<
matchGroups
.
size
();
++
i
){
// Find all vertices that match this one.
for
(
unsigned
short
j
=
0
;
j
<
vertices
.
size
();
++
j
)
{
if
(
vertices
[
i
]
==
vertices
[
j
]
)
{
matchGroups
[
i
].
vertexIndices
.
push_back
(
j
);
}
for
(
unsigned
short
j
=
i
+
1
;
j
<
vertices
.
size
();
++
j
)
{
/* for automatic regeneration we just consider
* identical positions, though the format would
* allow distinct positions to share a normal
*/
if
(
vertices
[
j
]
!=
vertices
[
i
]
)
continue
;
if
(
normals
[
j
]
!=
normals
[
i
]
)
continue
;
/* this index belongs to a group already */
if
(
sharing
[
i
]
!=
0
)
continue
;
/* remember this vertex' index */
group
.
vertexIndices
.
push_back
(
j
);
}
/* the currently observed vertex shares a normal with others */
if
(
(
group
.
numVertices
=
group
.
vertexIndices
.
size
()
)
>
0
)
{
/* this vertex belongs to the group as well */
group
.
vertexIndices
.
push_back
(
i
);
/* mark all of the participating vertices to belong to a group */
int
groupid
=
matchGroups
.
size
()
+
1
;
for
(
int
n
=
0
;
n
<
group
.
numVertices
;
n
++
)
sharing
[
group
.
vertexIndices
[
n
]]
=
groupid
;
/* register the group */
matchGroups
.
push_back
(
group
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment