From 11f290dbcca683487e41506d259759cf13dbe388 Mon Sep 17 00:00:00 2001 From: Simon Boorer Date: Tue, 21 Feb 2017 22:19:21 +1100 Subject: [PATCH 1/4] Fixed fatal error when no DAE file specified --- Tools/dae2dts/source/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Tools/dae2dts/source/main.cpp b/Tools/dae2dts/source/main.cpp index f92b9fa245..36c2690bf3 100644 --- a/Tools/dae2dts/source/main.cpp +++ b/Tools/dae2dts/source/main.cpp @@ -122,6 +122,10 @@ S32 TorqueMain( S32 argc, const char **argv ) { Con::errorf( "Error: no DAE file specified.\n" ); printUsage(); + + // Clean everything up. + StandardMainLoop::shutdown(); + return -1; } From 630c1428530659313b6f249d1699693bbd6926de Mon Sep 17 00:00:00 2001 From: Simon Boorer Date: Tue, 21 Feb 2017 22:59:53 +1100 Subject: [PATCH 2/4] Fixed initialising TSShape VBO with no GFX Device --- Engine/source/ts/loader/tsShapeLoader.cpp | 6 +++++- Tools/dae2dts/source/main.cpp | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Engine/source/ts/loader/tsShapeLoader.cpp b/Engine/source/ts/loader/tsShapeLoader.cpp index 49567d7e99..3d8816b3b0 100644 --- a/Engine/source/ts/loader/tsShapeLoader.cpp +++ b/Engine/source/ts/loader/tsShapeLoader.cpp @@ -1228,7 +1228,11 @@ void TSShapeLoader::install() shape->mRadius = (shape->mBounds.maxExtents - shape->center).len(); shape->tubeRadius = shape->mRadius; - shape->init(); + if (TSShape::smInitOnRead) + { + shape->init(); + } + shape->finalizeEditable(); } diff --git a/Tools/dae2dts/source/main.cpp b/Tools/dae2dts/source/main.cpp index 36c2690bf3..6454938871 100644 --- a/Tools/dae2dts/source/main.cpp +++ b/Tools/dae2dts/source/main.cpp @@ -156,6 +156,8 @@ S32 TorqueMain( S32 argc, const char **argv ) if ( verbose ) Con::printf( "Reading dae file...\n" ); + TSShape::smInitOnRead = false; + // Attempt to load the DAE file Resource shape = ResourceManager::get().load( srcPath ); if ( !shape ) From b0eb899c44a99076afb12f16530e1abfbd628c40 Mon Sep 17 00:00:00 2001 From: Simon Boorer Date: Tue, 21 Feb 2017 23:03:24 +1100 Subject: [PATCH 3/4] Fixed error deallocating TSShape resource --- Tools/dae2dts/source/main.cpp | 86 ++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/Tools/dae2dts/source/main.cpp b/Tools/dae2dts/source/main.cpp index 6454938871..a9b072390c 100644 --- a/Tools/dae2dts/source/main.cpp +++ b/Tools/dae2dts/source/main.cpp @@ -159,66 +159,68 @@ S32 TorqueMain( S32 argc, const char **argv ) TSShape::smInitOnRead = false; // Attempt to load the DAE file - Resource shape = ResourceManager::get().load( srcPath ); - if ( !shape ) { - Con::errorf( "Failed to convert DAE file: %s\n", srcPath.getFullPath() ); - failed = 1; - } - else - { - if ( compatMode && !shape->canWriteOldFormat() ) + Resource shape = ResourceManager::get().load( srcPath ); + if ( !shape ) { - Con::errorf( "Warning: Attempting to save to DTS v24 but the shape " - "contains v26 features. Resulting DTS file may not be valid." ); + Con::errorf( "Failed to convert DAE file: %s\n", srcPath.getFullPath() ); + failed = 1; } + else + { + if ( compatMode && !shape->canWriteOldFormat() ) + { + Con::errorf( "Warning: Attempting to save to DTS v24 but the shape " + "contains v26 features. Resulting DTS file may not be valid." ); + } - FileStream outStream; + FileStream outStream; - if ( saveDSQ ) - { - Torque::Path dsqPath( destPath ); - dsqPath.setExtension( "dsq" ); + if ( saveDSQ ) + { + Torque::Path dsqPath( destPath ); + dsqPath.setExtension( "dsq" ); - for ( S32 i = 0; i < shape->sequences.size(); i++ ) + for ( S32 i = 0; i < shape->sequences.size(); i++ ) + { + const String& seqName = shape->getName( shape->sequences[i].nameIndex ); + if ( verbose ) + Con::printf( "Writing DSQ file for sequence '%s'...\n", seqName.c_str() ); + + dsqPath.setFileName( destPath.getFileName() + "_" + seqName ); + + if ( outStream.open( dsqPath, Torque::FS::File::Write ) ) + { + shape->exportSequence( &outStream, shape->sequences[i], compatMode ); + outStream.close(); + } + else + { + Con::errorf( "Failed to save sequence to %s\n", dsqPath.getFullPath().c_str() ); + failed = 1; + } + } + } + if ( saveDTS ) { - const String& seqName = shape->getName( shape->sequences[i].nameIndex ); if ( verbose ) - Con::printf( "Writing DSQ file for sequence '%s'...\n", seqName.c_str() ); + Con::printf( "Writing DTS file...\n" ); - dsqPath.setFileName( destPath.getFileName() + "_" + seqName ); - - if ( outStream.open( dsqPath, Torque::FS::File::Write ) ) + if ( outStream.open( destPath, Torque::FS::File::Write ) ) { - shape->exportSequence( &outStream, shape->sequences[i], compatMode ); + if ( saveDSQ ) + shape->sequences.setSize(0); + + shape->write( &outStream, compatMode ); outStream.close(); } else { - Con::errorf( "Failed to save sequence to %s\n", dsqPath.getFullPath().c_str() ); + Con::errorf( "Failed to save shape to %s\n", destPath.getFullPath().c_str() ); failed = 1; } } } - if ( saveDTS ) - { - if ( verbose ) - Con::printf( "Writing DTS file...\n" ); - - if ( outStream.open( destPath, Torque::FS::File::Write ) ) - { - if ( saveDSQ ) - shape->sequences.setSize(0); - - shape->write( &outStream, compatMode ); - outStream.close(); - } - else - { - Con::errorf( "Failed to save shape to %s\n", destPath.getFullPath().c_str() ); - failed = 1; - } - } } // Clean everything up. From 6a9665084fdac17db119b4e4bbdbe4dc336157a7 Mon Sep 17 00:00:00 2001 From: Simon Boorer Date: Fri, 24 Feb 2017 15:08:39 +1100 Subject: [PATCH 4/4] Fixed clearing split vertex lists before saving --- Engine/source/ts/loader/tsShapeLoader.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Engine/source/ts/loader/tsShapeLoader.cpp b/Engine/source/ts/loader/tsShapeLoader.cpp index 3d8816b3b0..23e91a13ae 100644 --- a/Engine/source/ts/loader/tsShapeLoader.cpp +++ b/Engine/source/ts/loader/tsShapeLoader.cpp @@ -1231,9 +1231,8 @@ void TSShapeLoader::install() if (TSShape::smInitOnRead) { shape->init(); + shape->finalizeEditable(); } - - shape->finalizeEditable(); } void TSShapeLoader::computeBounds(Box3F& bounds)