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
d84a4637
Commit
d84a4637
authored
13 years ago
by
Amorilia
Browse files
Options
Downloads
Patches
Plain Diff
Added regression test for the skinning FixLinks problem.
parent
4cff6334
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/CMakeLists.txt
+2
-1
2 additions, 1 deletion
test/CMakeLists.txt
test/skin_test.cpp
+77
-0
77 additions, 0 deletions
test/skin_test.cpp
with
79 additions
and
1 deletion
test/CMakeLists.txt
+
2
−
1
View file @
d84a4637
...
...
@@ -8,7 +8,8 @@ include_directories(${Boost_INCLUDE_DIRS})
foreach
(
TEST
write_test
skinpart_test
ninode_test
)
ninode_test
skin_test
)
add_executable
(
${
TEST
}
${
TEST
}
.cpp
)
target_link_libraries
(
${
TEST
}
${
Boost_UNIT_TEST_FRAMEWORK_LIBRARY
}
niflib
)
add_test
(
niflib::
${
TEST
}
${
TEST
}
)
...
...
This diff is collapsed.
Click to expand it.
test/skin_test.cpp
0 → 100644
+
77
−
0
View file @
d84a4637
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MAIN
#include
<boost/test/unit_test.hpp>
#include
<sstream>
// stringstream
// evil hack to allow testing of private and protected data
#define private public
#define protected public
#include
"niflib.h"
#include
"obj/NiNode.h"
#include
"obj/NiSkinInstance.h"
#include
"obj/NiTriStrips.h"
#include
"obj/NiTriStripsData.h"
using
namespace
Niflib
;
using
namespace
std
;
BOOST_AUTO_TEST_SUITE
(
skin_test_suite
)
BOOST_AUTO_TEST_CASE
(
write_skin_test
)
{
stringstream
ss
;
stringstream
ss2
;
// create a simple nif tree with a skin partition
NiNodeRef
root
=
new
NiNode
;
NiNodeRef
bone
=
new
NiNode
;
NiTriStripsRef
shape
=
new
NiTriStrips
;
NiTriStripsDataRef
data
=
new
NiTriStripsData
;
// set hierarchy
shape
->
SetData
(
data
);
root
->
AddChild
(
DynamicCast
<
NiAVObject
>
(
shape
));
root
->
AddChild
(
DynamicCast
<
NiAVObject
>
(
bone
));
// add a triangle to the geometry
{
vector
<
Vector3
>
verts
;
vector
<
Triangle
>
tris
;
verts
.
push_back
(
Vector3
(
0
,
0
,
0
));
verts
.
push_back
(
Vector3
(
0
,
1
,
0
));
verts
.
push_back
(
Vector3
(
0
,
0
,
1
));
tris
.
push_back
(
Triangle
(
0
,
1
,
2
));
data
->
SetVertices
(
verts
);
data
->
SetTriangles
(
tris
);
}
// bind skin to bone
{
vector
<
NiNodeRef
>
bones
;
bones
.
push_back
(
bone
);
shape
->
BindSkin
(
bones
);
vector
<
SkinWeight
>
weights
;
SkinWeight
sw
;
sw
.
weight
=
1
;
sw
.
index
=
0
;
weights
.
push_back
(
sw
);
sw
.
index
=
1
;
weights
.
push_back
(
sw
);
sw
.
index
=
2
;
weights
.
push_back
(
sw
);
shape
->
SetBoneWeights
(
0
,
weights
);
shape
->
GenHardwareSkinInfo
();
}
// write, read, write, read, and check that nothing throws
// (we only write the shape, without the bones; obviously skinning
// will be lost but this is to check that it does not throw)
NiObjectRef
obj
;
BOOST_CHECK_NO_THROW
(
WriteNifTree
(
ss
,
shape
,
NifInfo
(
VER_20_0_0_5
)));
ss
.
seekg
(
0
);
BOOST_CHECK_NO_THROW
(
obj
=
ReadNifTree
(
ss
));
ss2
.
seekg
(
0
);
BOOST_CHECK_NO_THROW
(
WriteNifTree
(
ss2
,
obj
,
NifInfo
(
VER_20_0_0_5
)));
ss2
.
seekg
(
0
);
BOOST_CHECK_NO_THROW
(
obj
=
ReadNifTree
(
ss2
));
}
BOOST_AUTO_TEST_SUITE_END
()
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