@ -333,31 +333,9 @@ namespace
dst . rotation . mValues [ column ] [ row ] = src . getBasis ( ) . getRow ( row ) [ column ] ;
}
struct NifFileMock : Nif : : File
{
MOCK_METHOD ( Nif : : Record * , getRecord , ( std : : size_t ) , ( const , override ) ) ;
MOCK_METHOD ( std : : size_t , numRecords , ( ) , ( const , override ) ) ;
MOCK_METHOD ( Nif : : Record * , getRoot , ( std : : size_t ) , ( const , override ) ) ;
MOCK_METHOD ( std : : size_t , numRoots , ( ) , ( const , override ) ) ;
MOCK_METHOD ( std : : string , getString , ( uint32_t ) , ( const , override ) ) ;
MOCK_METHOD ( void , setUseSkinning , ( bool ) , ( override ) ) ;
MOCK_METHOD ( bool , getUseSkinning , ( ) , ( const , override ) ) ;
MOCK_METHOD ( std : : filesystem : : path , getFilename , ( ) , ( const , override ) ) ;
MOCK_METHOD ( std : : string , getHash , ( ) , ( const , override ) ) ;
MOCK_METHOD ( unsigned int , getVersion , ( ) , ( const , override ) ) ;
MOCK_METHOD ( unsigned int , getUserVersion , ( ) , ( const , override ) ) ;
MOCK_METHOD ( unsigned int , getBethVersion , ( ) , ( const , override ) ) ;
} ;
struct RecordMock : Nif : : Record
{
MOCK_METHOD ( void , read , ( Nif : : NIFStream * nif ) , ( override ) ) ;
} ;
struct TestBulletNifLoader : Test
{
BulletNifLoader mLoader ;
const StrictMock < const NifFileMock > mNifFile ;
Nif : : Node mNode ;
Nif : : Node mNode2 ;
Nif : : NiNode mNiNode ;
@ -412,16 +390,15 @@ namespace
= { osg : : Vec3f ( 0 , 0 , 0 ) , osg : : Vec3f ( 1 , 0 , 0 ) , osg : : Vec3f ( 1 , 1 , 0 ) , osg : : Vec3f ( 0 , 1 , 0 ) } ;
mNiTriStripsData . strips = { { 0 , 1 , 2 , 3 } } ;
mNiTriStrips . data = Nif : : NiGeometryDataPtr ( & mNiTriStripsData ) ;
EXPECT_CALL ( mNifFile , getHash ( ) ) . WillOnce ( Return ( mHash ) ) ;
}
} ;
TEST_F ( TestBulletNifLoader , for_zero_num_roots_should_return_default )
{
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 0 ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
Resource : : BulletShape expected ;
@ -432,10 +409,11 @@ namespace
TEST_F ( TestBulletNifLoader , should_ignore_nullptr_root )
{
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( nullptr ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( nullptr ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
Resource : : BulletShape expected ;
@ -444,10 +422,11 @@ namespace
TEST_F ( TestBulletNifLoader , for_default_root_nif_node_should_return_default )
{
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
Resource : : BulletShape expected ;
@ -458,10 +437,11 @@ namespace
{
mNode . recType = Nif : : RC_RootCollisionNode ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
Resource : : BulletShape expected ;
@ -470,10 +450,11 @@ namespace
TEST_F ( TestBulletNifLoader , for_default_root_nif_node_and_filename_starting_with_x_should_return_default )
{
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " xtest.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " xtest.nif " ) ;
file . mRoots . push_back ( & mNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
Resource : : BulletShape expected ;
@ -489,10 +470,11 @@ namespace
mNode . bounds . box . extents = osg : : Vec3f ( 1 , 2 , 3 ) ;
mNode . bounds . box . center = osg : : Vec3f ( - 1 , - 2 , - 3 ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
Resource : : BulletShape expected ;
expected . mCollisionBox . mExtents = osg : : Vec3f ( 1 , 2 , 3 ) ;
@ -515,10 +497,11 @@ namespace
mNode . parents . push_back ( & mNiNode ) ;
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNode ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
Resource : : BulletShape expected ;
expected . mCollisionBox . mExtents = osg : : Vec3f ( 1 , 2 , 3 ) ;
@ -547,10 +530,11 @@ namespace
mNiNode . bounds . box . center = osg : : Vec3f ( - 4 , - 5 , - 6 ) ;
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNode ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
Resource : : BulletShape expected ;
expected . mCollisionBox . mExtents = osg : : Vec3f ( 1 , 2 , 3 ) ;
@ -585,10 +569,11 @@ namespace
mNiNode . bounds . box . center = osg : : Vec3f ( - 7 , - 8 , - 9 ) ;
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNode ) , Nif : : NodePtr ( & mNode2 ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
Resource : : BulletShape expected ;
expected . mCollisionBox . mExtents = osg : : Vec3f ( 1 , 2 , 3 ) ;
@ -623,10 +608,11 @@ namespace
mNiNode . bounds . box . center = osg : : Vec3f ( - 7 , - 8 , - 9 ) ;
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNode ) , Nif : : NodePtr ( & mNode2 ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
Resource : : BulletShape expected ;
expected . mCollisionBox . mExtents = osg : : Vec3f ( 4 , 5 , 6 ) ;
@ -647,10 +633,11 @@ namespace
mNode . bounds . box . extents = osg : : Vec3f ( 1 , 2 , 3 ) ;
mNode . bounds . box . center = osg : : Vec3f ( - 1 , - 2 , - 3 ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
Resource : : BulletShape expected ;
expected . mCollisionBox . mExtents = osg : : Vec3f ( 1 , 2 , 3 ) ;
@ -661,10 +648,11 @@ namespace
TEST_F ( TestBulletNifLoader , for_tri_shape_root_node_should_return_shape_with_triangle_mesh_shape )
{
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiTriShape ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiTriShape ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -682,10 +670,11 @@ namespace
mNiTriShape . bounds . box . extents = osg : : Vec3f ( 1 , 2 , 3 ) ;
mNiTriShape . bounds . box . center = osg : : Vec3f ( - 1 , - 2 , - 3 ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiTriShape ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiTriShape ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
Resource : : BulletShape expected ;
expected . mCollisionBox . mExtents = osg : : Vec3f ( 1 , 2 , 3 ) ;
@ -699,10 +688,11 @@ namespace
mNiTriShape . parents . push_back ( & mNiNode ) ;
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriShape ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -719,10 +709,11 @@ namespace
mNiNode2 . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriShape ) } ) ) ;
mNiTriShape . parents . push_back ( & mNiNode2 ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -739,10 +730,11 @@ namespace
mNiNode . children
= Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriShape ) , Nif : : NodePtr ( & mNiTriShape2 ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 1 ) , btVector3 ( 1 , 0 , 1 ) , btVector3 ( 1 , 1 , 1 ) ) ;
@ -760,10 +752,11 @@ namespace
mNiTriShape . parents . push_back ( & mNiNode ) ;
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriShape ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " xtest.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " xtest.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -779,10 +772,11 @@ namespace
copy ( mTransform , mNiTriShape . trafo ) ;
mNiTriShape . trafo . scale = 3 ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiTriShape ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " xtest.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " xtest.nif " ) ;
file . mRoots . push_back ( & mNiTriShape ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -806,10 +800,11 @@ namespace
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriShape ) } ) ) ;
mNiNode . trafo . scale = 4 ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " xtest.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " xtest.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -840,10 +835,11 @@ namespace
Nif : : NodePtr ( & mNiTriShape2 ) ,
} ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " xtest.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " xtest.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -876,10 +872,11 @@ namespace
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriShape ) } ) ) ;
mNiNode . trafo . scale = 4 ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -912,10 +909,11 @@ namespace
} ) ) ;
mNiNode . trafo . scale = 4 ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle (
@ -943,11 +941,12 @@ namespace
mNiTriShape . parents . push_back ( & mNiNode ) ;
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriShape ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 2 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 1 ) ) . WillOnce ( Return ( & mNiTriShape2 ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " xtest.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " xtest.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mRoots . push_back ( & mNiTriShape2 ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -974,10 +973,11 @@ namespace
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriShape ) } ) ) ;
mNiNode . recType = Nif : : RC_AvoidNode ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -993,10 +993,11 @@ namespace
mNiTriShape . parents . push_back ( & mNiNode ) ;
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriShape ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
Resource : : BulletShape expected ;
@ -1011,10 +1012,11 @@ namespace
mNiTriShape . parents . push_back ( & mNiNode ) ;
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriShape ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
Resource : : BulletShape expected ;
@ -1030,10 +1032,11 @@ namespace
mNiTriShape . parents . push_back ( & mNiNode ) ;
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriShape ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -1054,10 +1057,11 @@ namespace
mNiTriShape . parents . push_back ( & mNiNode ) ;
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriShape ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -1077,10 +1081,11 @@ namespace
mNiTriShape . parents . push_back ( & mNiNode ) ;
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriShape ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -1101,10 +1106,11 @@ namespace
mNiTriShape . parents . push_back ( & mNiNode ) ;
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriShape ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -1131,10 +1137,11 @@ namespace
mNiNode . children = Nif : : NodeList (
std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & niTriShape ) , Nif : : NodePtr ( & emptyCollisionNode ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -1154,10 +1161,11 @@ namespace
mNiTriShape . parents . push_back ( & mNiNode ) ;
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriShape ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
Resource : : BulletShape expected ;
@ -1177,10 +1185,11 @@ namespace
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiNode2 ) } ) ) ;
mNiNode . recType = Nif : : RC_NiNode ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -1194,10 +1203,11 @@ namespace
{
mNiTriShape . data = Nif : : NiGeometryDataPtr ( & mNiTriStripsData ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiTriShape ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiTriShape ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
const Resource : : BulletShape expected ;
@ -1206,10 +1216,11 @@ namespace
TEST_F ( TestBulletNifLoader , for_tri_strips_root_node_should_return_shape_with_triangle_mesh_shape )
{
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiTriStrips ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiTriStrips ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -1224,10 +1235,11 @@ namespace
{
mNiTriStrips . data = Nif : : NiGeometryDataPtr ( & mNiTriShapeData ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiTriStrips ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiTriStrips ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
const Resource : : BulletShape expected ;
@ -1238,10 +1250,11 @@ namespace
{
mNiTriStripsData . strips . clear ( ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiTriStrips ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiTriStrips ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
const Resource : : BulletShape expected ;
@ -1252,10 +1265,11 @@ namespace
{
mNiTriStripsData . strips . front ( ) = { 0 , 1 } ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiTriStrips ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiTriStrips ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
const Resource : : BulletShape expected ;
@ -1269,10 +1283,11 @@ namespace
mNiNode . recType = Nif : : RC_AvoidNode ;
mNiTriStripsData . strips . front ( ) = { 0 , 1 } ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiTriStrips ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " test.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " test.nif " ) ;
file . mRoots . push_back ( & mNiTriStrips ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
const Resource : : BulletShape expected ;
@ -1285,10 +1300,11 @@ namespace
mNiTriStrips . parents . push_back ( & mNiNode ) ;
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriStrips ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 1 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " xtest.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " xtest.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
const Resource : : BulletShape expected ;
@ -1301,11 +1317,12 @@ namespace
mNiTriShape . parents . push_back ( & mNiNode ) ;
mNiNode . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriShape ) } ) ) ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 2 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 1 ) ) . WillOnce ( Return ( & mNiTriStrips ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " xtest.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " xtest.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mRoots . push_back ( & mNiTriStrips ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles ( new btTriangleMesh ( false ) ) ;
triangles - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;
@ -1330,11 +1347,12 @@ namespace
mNiNode2 . children = Nif : : NodeList ( std : : vector < Nif : : NodePtr > ( { Nif : : NodePtr ( & mNiTriShape ) } ) ) ;
mNiNode2 . trafo . scale = 3 ;
EXPECT_CALL ( mNifFile , numRoots ( ) ) . WillOnce ( Return ( 2 ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 0 ) ) . WillOnce ( Return ( & mNiNode ) ) ;
EXPECT_CALL ( mNifFile , getRoot ( 1 ) ) . WillOnce ( Return ( & mNiNode2 ) ) ;
EXPECT_CALL ( mNifFile , getFilename ( ) ) . WillOnce ( Return ( " xtest.nif " ) ) ;
const auto result = mLoader . load ( mNifFile ) ;
Nif : : NIFFile file ( " xtest.nif " ) ;
file . mRoots . push_back ( & mNiNode ) ;
file . mRoots . push_back ( & mNiNode2 ) ;
file . mHash = mHash ;
const auto result = mLoader . load ( file ) ;
std : : unique_ptr < btTriangleMesh > triangles1 ( new btTriangleMesh ( false ) ) ;
triangles1 - > addTriangle ( btVector3 ( 0 , 0 , 0 ) , btVector3 ( 1 , 0 , 0 ) , btVector3 ( 1 , 1 , 0 ) ) ;