From 3885e8bfb624a73a98ff76b09125dcc3b2670def Mon Sep 17 00:00:00 2001 From: codereader Date: Sun, 4 Apr 2021 10:24:17 +0200 Subject: [PATCH] #5576: Move the pm_ase.c code to a C++ source file, fix a few compilation errors. No ASE parsing possible at this point. --- radiantcore/CMakeLists.txt | 2 +- .../lib/pm_ase.c => import/AseModel.cpp} | 31 +++++-------------- radiantcore/model/import/AseModelLoader.cpp | 10 +++--- tools/msvc/DarkRadiantCore.vcxproj | 19 +----------- tools/msvc/DarkRadiantCore.vcxproj.filters | 6 ++-- 5 files changed, 17 insertions(+), 51 deletions(-) rename radiantcore/model/{picomodel/lib/pm_ase.c => import/AseModel.cpp} (97%) diff --git a/radiantcore/CMakeLists.txt b/radiantcore/CMakeLists.txt index a68b11f924..f95875debc 100644 --- a/radiantcore/CMakeLists.txt +++ b/radiantcore/CMakeLists.txt @@ -154,6 +154,7 @@ add_library(radiantcore MODULE model/ModelFormatManager.cpp model/NullModel.cpp model/NullModelNode.cpp + model/import/AseModel.cpp model/import/AseModelLoader.cpp model/import/ModelImporterBase.cpp model/picomodel/PicoModelLoader.cpp @@ -175,7 +176,6 @@ add_library(radiantcore MODULE model/picomodel/lib/picomodel.c model/picomodel/lib/picomodules.c model/picomodel/lib/pm_3ds.c - model/picomodel/lib/pm_ase.c model/picomodel/lib/pm_fm.c model/picomodel/lib/pm_lwo.c model/picomodel/lib/pm_md2.c diff --git a/radiantcore/model/picomodel/lib/pm_ase.c b/radiantcore/model/import/AseModel.cpp similarity index 97% rename from radiantcore/model/picomodel/lib/pm_ase.c rename to radiantcore/model/import/AseModel.cpp index 7a31871f83..d673a10c56 100644 --- a/radiantcore/model/picomodel/lib/pm_ase.c +++ b/radiantcore/model/import/AseModel.cpp @@ -42,7 +42,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* dependencies */ -#include "picointernal.h" +#include "../picomodel/lib/picointernal.h" #ifdef DEBUG_PM_ASE #include "time.h" @@ -139,7 +139,7 @@ aseSubMaterial_t* _ase_get_submaterial_or_default ( aseMaterial_t* materials, in static aseMaterial_t* _ase_add_material( aseMaterial_t **list, int mtlIdParent ) { - aseMaterial_t *mtl = _pico_calloc( 1, sizeof( aseMaterial_t ) ); + aseMaterial_t *mtl = (aseMaterial_t*)_pico_calloc( 1, sizeof( aseMaterial_t ) ); mtl->mtlId = mtlIdParent; mtl->subMtls = NULL; mtl->next = *list; @@ -151,7 +151,7 @@ static aseMaterial_t* _ase_add_material( aseMaterial_t **list, int mtlIdParent ) static aseSubMaterial_t* _ase_add_submaterial( aseMaterial_t **list, int mtlIdParent, int subMtlId, picoShader_t* shader ) { aseMaterial_t *parent = _ase_get_material( *list, mtlIdParent ); - aseSubMaterial_t *subMtl = _pico_calloc( 1, sizeof ( aseSubMaterial_t ) ); + aseSubMaterial_t *subMtl = (aseSubMaterial_t*)_pico_calloc( 1, sizeof ( aseSubMaterial_t ) ); /* Initialise some values */ subMtl->uOffset = 0.0f; @@ -647,21 +647,21 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD ) if (!_pico_parse_int( p, &numVertices) ) _ase_error_return("Missing MESH_NUMVERTEX value"); - vertices = _pico_calloc(numVertices, sizeof(aseVertex_t)); + vertices = (aseVertex_t*)_pico_calloc(numVertices, sizeof(aseVertex_t)); } else if (!_pico_stricmp(p->token,"*mesh_numfaces")) { if (!_pico_parse_int( p, &numFaces) ) _ase_error_return("Missing MESH_NUMFACES value"); - faces = _pico_calloc(numFaces, sizeof(aseFace_t)); + faces = (aseFace_t*)_pico_calloc(numFaces, sizeof(aseFace_t)); } else if (!_pico_stricmp(p->token,"*mesh_numtvertex")) { if (!_pico_parse_int( p, &numTextureVertices) ) _ase_error_return("Missing MESH_NUMTVERTEX value"); - texcoords = _pico_calloc(numTextureVertices, sizeof(aseTexCoord_t)); + texcoords = (aseTexCoord_t*)_pico_calloc(numTextureVertices, sizeof(aseTexCoord_t)); } else if (!_pico_stricmp(p->token,"*mesh_numtvfaces")) { @@ -673,7 +673,7 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD ) if (!_pico_parse_int( p, &numColorVertices) ) _ase_error_return("Missing MESH_NUMCVERTEX value"); - colors = _pico_calloc(numColorVertices, sizeof(aseColor_t)); + colors = (aseColor_t*)_pico_calloc(numColorVertices, sizeof(aseColor_t)); memset( colors, 255, numColorVertices * sizeof( aseColor_t ) ); /* ydnar: force colors to white initially */ } else if (!_pico_stricmp(p->token,"*mesh_numcvfaces")) @@ -1156,7 +1156,7 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD ) char* name = _pico_parse(p,0); if (name == NULL) _ase_error_return("Missing material map bitmap name"); - mapname = _pico_alloc ( strlen ( name ) + 1 ); + mapname = (char*)_pico_alloc ( strlen ( name ) + 1 ); strcpy ( mapname, name ); /* skip rest and continue with next token */ _pico_parse_skip_rest( p ); @@ -1348,18 +1348,3 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD ) return model; } -/* pico file format module definition */ -const picoModule_t picoModuleASE = -{ - "1.0", /* module version string */ - "Autodesk 3DSMAX ASCII", /* module display name */ - "Jared Hefty, seaw0lf", /* author's name */ - "2003 Jared Hefty, 2002 seaw0lf", /* module copyright */ - { - "ase",NULL,NULL,NULL /* default extensions to use */ - }, - _ase_canload, /* validation routine */ - _ase_load, /* load routine */ - NULL, /* save validation routine */ - NULL /* save routine */ -}; diff --git a/radiantcore/model/import/AseModelLoader.cpp b/radiantcore/model/import/AseModelLoader.cpp index 489dfad1b5..a6943f15eb 100644 --- a/radiantcore/model/import/AseModelLoader.cpp +++ b/radiantcore/model/import/AseModelLoader.cpp @@ -7,11 +7,6 @@ #include "../StaticModel.h" #include "../picomodel/PicoModelLoader.h" -extern "C" -{ - extern const picoModule_t picoModuleASE; -} - namespace model { @@ -42,6 +37,7 @@ IModelPtr AseModelLoader::loadModelFromPath(const std::string& path) return IModelPtr(); } +#if 0 auto* model = PicoModuleLoadModelStream( &picoModuleASE, &file->getInputStream(), @@ -60,7 +56,6 @@ IModelPtr AseModelLoader::loadModelFromPath(const std::string& path) auto surfaces = PicoModelLoader::CreateSurfaces(model, string::to_lower_copy(getExtension())); auto modelObj = std::make_shared(surfaces); - // Set the filename modelObj->setFilename(os::getFilename(file->getName())); modelObj->setModelPath(path); @@ -68,6 +63,9 @@ IModelPtr AseModelLoader::loadModelFromPath(const std::string& path) PicoFreeModel(model); return modelObj; +#else + return IModelPtr(); +#endif } } diff --git a/tools/msvc/DarkRadiantCore.vcxproj b/tools/msvc/DarkRadiantCore.vcxproj index 3ad885b6c5..bc44eea733 100644 --- a/tools/msvc/DarkRadiantCore.vcxproj +++ b/tools/msvc/DarkRadiantCore.vcxproj @@ -151,6 +151,7 @@ + @@ -417,24 +418,6 @@ - - CompileAsC - CompileAsC - CompileAsC - CompileAsC - NotUsing - NotUsing - NotUsing - NotUsing - - - - - - - - - CompileAsC CompileAsC diff --git a/tools/msvc/DarkRadiantCore.vcxproj.filters b/tools/msvc/DarkRadiantCore.vcxproj.filters index b587873242..187a10a36d 100644 --- a/tools/msvc/DarkRadiantCore.vcxproj.filters +++ b/tools/msvc/DarkRadiantCore.vcxproj.filters @@ -667,9 +667,6 @@ src\model\picomodel\lib - - src\model\picomodel\lib - src\model\picomodel\lib @@ -1036,6 +1033,9 @@ src\model + + src\model\import +