Skip to content

Commit

Permalink
#5576: Move the pm_ase.c code to a C++ source file, fix a few compila…
Browse files Browse the repository at this point in the history
…tion errors. No ASE parsing possible at this point.
  • Loading branch information
codereader committed Apr 5, 2021
1 parent 670e724 commit daf8333
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 51 deletions.
2 changes: 1 addition & 1 deletion radiantcore/CMakeLists.txt
Expand Up @@ -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
Expand All @@ -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
Expand Down
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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"))
{
Expand All @@ -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"))
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 */
};
10 changes: 4 additions & 6 deletions radiantcore/model/import/AseModelLoader.cpp
Expand Up @@ -7,11 +7,6 @@
#include "../StaticModel.h"
#include "../picomodel/PicoModelLoader.h"

extern "C"
{
extern const picoModule_t picoModuleASE;
}

namespace model
{

Expand Down Expand Up @@ -42,6 +37,7 @@ IModelPtr AseModelLoader::loadModelFromPath(const std::string& path)
return IModelPtr();
}

#if 0
auto* model = PicoModuleLoadModelStream(
&picoModuleASE,
&file->getInputStream(),
Expand All @@ -60,14 +56,16 @@ IModelPtr AseModelLoader::loadModelFromPath(const std::string& path)
auto surfaces = PicoModelLoader::CreateSurfaces(model, string::to_lower_copy(getExtension()));

auto modelObj = std::make_shared<StaticModel>(surfaces);

// Set the filename
modelObj->setFilename(os::getFilename(file->getName()));
modelObj->setModelPath(path);

PicoFreeModel(model);

return modelObj;
#else
return IModelPtr();
#endif
}

}
19 changes: 1 addition & 18 deletions tools/msvc/DarkRadiantCore.vcxproj
Expand Up @@ -151,6 +151,7 @@
<ClCompile Include="..\..\radiantcore\model\export\PatchSurface.cpp" />
<ClCompile Include="..\..\radiantcore\model\export\ScaledModelExporter.cpp" />
<ClCompile Include="..\..\radiantcore\model\export\WavefrontExporter.cpp" />
<ClCompile Include="..\..\radiantcore\model\import\AseModel.cpp" />
<ClCompile Include="..\..\radiantcore\model\import\AseModelLoader.cpp" />
<ClCompile Include="..\..\radiantcore\model\import\ModelImporterBase.cpp" />
<ClCompile Include="..\..\radiantcore\model\md5\MD5Anim.cpp" />
Expand Down Expand Up @@ -417,24 +418,6 @@
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</ForcedIncludeFiles>
</ClCompile>
<ClCompile Include="..\..\radiantcore\model\picomodel\lib\pm_ase.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsC</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsC</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">CompileAsC</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsC</CompileAs>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</ForcedIncludeFiles>
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</ForcedIncludeFiles>
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</ForcedIncludeFiles>
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</ForcedIncludeFiles>
</ClCompile>
<ClCompile Include="..\..\radiantcore\model\picomodel\lib\pm_fm.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsC</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsC</CompileAs>
Expand Down
6 changes: 3 additions & 3 deletions tools/msvc/DarkRadiantCore.vcxproj.filters
Expand Up @@ -667,9 +667,6 @@
<ClCompile Include="..\..\radiantcore\model\picomodel\lib\pm_3ds.c">
<Filter>src\model\picomodel\lib</Filter>
</ClCompile>
<ClCompile Include="..\..\radiantcore\model\picomodel\lib\pm_ase.c">
<Filter>src\model\picomodel\lib</Filter>
</ClCompile>
<ClCompile Include="..\..\radiantcore\model\picomodel\lib\pm_fm.c">
<Filter>src\model\picomodel\lib</Filter>
</ClCompile>
Expand Down Expand Up @@ -1036,6 +1033,9 @@
<ClCompile Include="..\..\radiantcore\model\StaticModelSurface.cpp">
<Filter>src\model</Filter>
</ClCompile>
<ClCompile Include="..\..\radiantcore\model\import\AseModel.cpp">
<Filter>src\model\import</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\radiantcore\modulesystem\ModuleLoader.h">
Expand Down

0 comments on commit daf8333

Please sign in to comment.