mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-08 21:24:34 +00:00
Merge pull request #1761 from marauder2k9-torque/Fix-GlobalRegistrionVectors-XcodeIssue
Fix for extension registrations for different Resource types
This commit is contained in:
commit
059417e593
8 changed files with 46 additions and 32 deletions
|
|
@ -38,8 +38,13 @@ using namespace Torque;
|
|||
|
||||
const U32 GBitmap::csFileVersion = 3;
|
||||
|
||||
Vector<GBitmap::Registration> GBitmap::sRegistrations( __FILE__, __LINE__ );
|
||||
Vector<GBitmap::Registration>& GBitmap::getRegistrations()
|
||||
{
|
||||
static Vector<GBitmap::Registration> * regs =
|
||||
new Vector<GBitmap::Registration>(__FILE__, __LINE__);
|
||||
|
||||
return *regs;
|
||||
}
|
||||
|
||||
GBitmap::GBitmap()
|
||||
: mInternalFormat(GFXFormatR8G8B8),
|
||||
|
|
@ -198,24 +203,24 @@ U32 GBitmap::getFormatBytesPerPixel(GFXFormat fmt)
|
|||
|
||||
void GBitmap::sRegisterFormat( const GBitmap::Registration ® )
|
||||
{
|
||||
U32 insert = sRegistrations.size();
|
||||
for ( U32 i = 0; i < sRegistrations.size(); i++ )
|
||||
U32 insert = GBitmap::getRegistrations().size();
|
||||
for ( U32 i = 0; i < GBitmap::getRegistrations().size(); i++ )
|
||||
{
|
||||
if ( sRegistrations[i].priority <= reg.priority )
|
||||
if ( GBitmap::getRegistrations()[i].priority <= reg.priority )
|
||||
{
|
||||
insert = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sRegistrations.insert( insert, reg );
|
||||
GBitmap::getRegistrations().insert( insert, reg );
|
||||
}
|
||||
|
||||
const GBitmap::Registration *GBitmap::sFindRegInfo( const String &extension )
|
||||
{
|
||||
for ( U32 i = 0; i < GBitmap::sRegistrations.size(); i++ )
|
||||
for ( U32 i = 0; i < GBitmap::getRegistrations().size(); i++ )
|
||||
{
|
||||
const GBitmap::Registration ® = GBitmap::sRegistrations[i];
|
||||
const GBitmap::Registration ® = GBitmap::getRegistrations()[i];
|
||||
const Vector<String> &extensions = reg.extensions;
|
||||
|
||||
for ( U32 j = 0; j < extensions.size(); ++j )
|
||||
|
|
@ -236,9 +241,9 @@ bool GBitmap::sFindFile( const Path &path, Path *outPath )
|
|||
|
||||
Path tryPath( path );
|
||||
|
||||
for ( U32 i = 0; i < sRegistrations.size(); i++ )
|
||||
for ( U32 i = 0; i < GBitmap::getRegistrations().size(); i++ )
|
||||
{
|
||||
const Registration ® = sRegistrations[i];
|
||||
const Registration ® = GBitmap::getRegistrations()[i];
|
||||
const Vector<String> &extensions = reg.extensions;
|
||||
|
||||
for ( U32 j = 0; j < extensions.size(); ++j )
|
||||
|
|
@ -266,9 +271,9 @@ bool GBitmap::sFindFiles( const Path &path, Vector<Path> *outFoundPaths )
|
|||
|
||||
Path tryPath( path );
|
||||
|
||||
for ( U32 i = 0; i < GBitmap::sRegistrations.size(); i++ )
|
||||
for ( U32 i = 0; i < GBitmap::getRegistrations().size(); i++ )
|
||||
{
|
||||
const GBitmap::Registration ® = GBitmap::sRegistrations[i];
|
||||
const GBitmap::Registration ® = GBitmap::getRegistrations()[i];
|
||||
const Vector<String> &extensions = reg.extensions;
|
||||
|
||||
for ( U32 j = 0; j < extensions.size(); ++j )
|
||||
|
|
@ -292,9 +297,9 @@ String GBitmap::sGetExtensionList()
|
|||
{
|
||||
String list;
|
||||
|
||||
for ( U32 i = 0; i < sRegistrations.size(); i++ )
|
||||
for ( U32 i = 0; i < GBitmap::getRegistrations().size(); i++ )
|
||||
{
|
||||
const Registration ® = sRegistrations[i];
|
||||
const Registration ® = GBitmap::getRegistrations()[i];
|
||||
for ( U32 j = 0; j < reg.extensions.size(); j++ )
|
||||
{
|
||||
list += reg.extensions[j];
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ public:
|
|||
template<class T, dsize_t mapLength>
|
||||
void swizzle(const Swizzle<T,mapLength> *s);
|
||||
|
||||
static Vector<Registration> sRegistrations;
|
||||
static Vector<Registration>& getRegistrations();
|
||||
|
||||
private:
|
||||
GFXFormat mInternalFormat;
|
||||
|
|
|
|||
|
|
@ -858,14 +858,14 @@ Torque::Path GFXTextureManager::validatePath(const Torque::Path &path)
|
|||
|
||||
// Now loop through the rest of the GBitmap extensions
|
||||
// to see if we have any matches
|
||||
for (U32 i = 0; i < GBitmap::sRegistrations.size(); i++)
|
||||
for (U32 i = 0; i < GBitmap::getRegistrations().size(); i++)
|
||||
{
|
||||
// If we have gotten a match (either in this loop or before)
|
||||
// then we can exit
|
||||
if (textureExt)
|
||||
break;
|
||||
|
||||
const GBitmap::Registration ® = GBitmap::sRegistrations[i];
|
||||
const GBitmap::Registration ® = GBitmap::getRegistrations()[i];
|
||||
const Vector<String> &extensions = reg.extensions;
|
||||
|
||||
for (U32 j = 0; j < extensions.size(); ++j)
|
||||
|
|
|
|||
|
|
@ -407,9 +407,9 @@ void ColladaShapeLoader::computeBounds(Box3F& bounds)
|
|||
String findTextureExtension(const Torque::Path &texPath)
|
||||
{
|
||||
Torque::Path path(texPath);
|
||||
for(S32 i = 0;i < GBitmap::sRegistrations.size();++i)
|
||||
for(S32 i = 0;i < GBitmap::getRegistrations().size();++i)
|
||||
{
|
||||
GBitmap::Registration ® = GBitmap::sRegistrations[i];
|
||||
GBitmap::Registration ® = GBitmap::getRegistrations()[i];
|
||||
for(S32 j = 0;j < reg.extensions.size();++j)
|
||||
{
|
||||
path.setExtension(reg.extensions[j]);
|
||||
|
|
|
|||
|
|
@ -1302,9 +1302,9 @@ String TSShapeLoader::getFormatExtensions()
|
|||
{
|
||||
// "*.dsq TAB *.dae TAB
|
||||
StringBuilder output;
|
||||
for(U32 n = 0; n < TSShape::sRegistrations.size(); ++n)
|
||||
for(U32 n = 0; n < TSShape::getRegistrations().size(); ++n)
|
||||
{
|
||||
TSShape::ShapeRegistration reg = TSShape::sRegistrations[n];
|
||||
TSShape::ShapeRegistration reg = TSShape::getRegistrations()[n];
|
||||
for (U32 i = 0; i < reg.extensions.size(); i++)
|
||||
{
|
||||
TSShape::ShapeFormat format = reg.extensions[i];
|
||||
|
|
@ -1320,9 +1320,9 @@ String TSShapeLoader::getFormatFilters()
|
|||
{
|
||||
// "DSQ Files|*.dsq|COLLADA Files|*.dae|"
|
||||
StringBuilder output;
|
||||
for (U32 n = 0; n < TSShape::sRegistrations.size(); ++n)
|
||||
for (U32 n = 0; n < TSShape::getRegistrations().size(); ++n)
|
||||
{
|
||||
TSShape::ShapeRegistration reg = TSShape::sRegistrations[n];
|
||||
TSShape::ShapeRegistration reg = TSShape::getRegistrations()[n];
|
||||
for (U32 i = 0; i < reg.extensions.size(); i++)
|
||||
{
|
||||
TSShape::ShapeFormat format = reg.extensions[i];
|
||||
|
|
|
|||
|
|
@ -38,19 +38,28 @@
|
|||
#include "core/stream/fileStream.h"
|
||||
#include "core/fileObject.h"
|
||||
|
||||
Vector<TSShape::ShapeRegistration> TSShape::sRegistrations(__FILE__, __LINE__);
|
||||
// Vector<TSShape::ShapeRegistration> TSShape::sShapeRegistrations(__FILE__, __LINE__);
|
||||
|
||||
Vector<TSShape::ShapeRegistration>& TSShape::getRegistrations()
|
||||
{
|
||||
static Vector<TSShape::ShapeRegistration>* regs =
|
||||
new Vector<TSShape::ShapeRegistration>(__FILE__, __LINE__);
|
||||
|
||||
return *regs;
|
||||
}
|
||||
|
||||
void TSShape::sRegisterFormat(const ShapeRegistration& reg)
|
||||
{
|
||||
U32 insert = sRegistrations.size();
|
||||
sRegistrations.insert(insert, reg);
|
||||
U32 insert = TSShape::getRegistrations().size();
|
||||
TSShape::getRegistrations().insert(insert, reg);
|
||||
}
|
||||
|
||||
const TSShape::ShapeRegistration* TSShape::sFindRegInfo(const String& extension, bool exporting)
|
||||
|
||||
const TSShape::ShapeRegistration* TSShape::sFindShapeRegInfo(const String& extension, bool exporting)
|
||||
{
|
||||
for (U32 i = 0; i < TSShape::sRegistrations.size(); i++)
|
||||
for (U32 i = 0; i < TSShape::getRegistrations().size(); i++)
|
||||
{
|
||||
const TSShape::ShapeRegistration& reg = TSShape::sRegistrations[i];
|
||||
const TSShape::ShapeRegistration& reg = TSShape::getRegistrations()[i];
|
||||
const Vector<ShapeFormat>& extensions = exporting ? reg.export_extensions : reg.extensions;
|
||||
|
||||
for (U32 j = 0; j < extensions.size(); j++)
|
||||
|
|
@ -2358,7 +2367,7 @@ template<> void *Resource<TSShape>::create(const Torque::Path &path)
|
|||
}
|
||||
else
|
||||
{
|
||||
const TSShape::ShapeRegistration* regInfo = TSShape::sFindRegInfo(extension);
|
||||
const TSShape::ShapeRegistration* regInfo = TSShape::sFindShapeRegInfo(extension);
|
||||
if (regInfo == NULL)
|
||||
{
|
||||
readSuccess = false;
|
||||
|
|
|
|||
|
|
@ -122,8 +122,8 @@ public:
|
|||
};
|
||||
|
||||
static void sRegisterFormat(const ShapeRegistration& reg);
|
||||
static const ShapeRegistration* sFindRegInfo(const String& extension, bool exporting = false);
|
||||
static Vector<ShapeRegistration> sRegistrations;
|
||||
static const ShapeRegistration* sFindShapeRegInfo(const String& extension, bool exporting = false);
|
||||
static Vector<ShapeRegistration>& getRegistrations();
|
||||
|
||||
/// Nodes hold the transforms in the shape's tree. They are the bones of the skeleton.
|
||||
struct Node
|
||||
|
|
|
|||
|
|
@ -1361,7 +1361,7 @@ bool TSShape::isShapeFileType(Torque::Path filePath)
|
|||
{
|
||||
String fileExt = filePath.getExtension();
|
||||
|
||||
if (TSShape::sFindRegInfo(fileExt))
|
||||
if (TSShape::sFindShapeRegInfo(fileExt))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue