Merge pull request #1761 from marauder2k9-torque/Fix-GlobalRegistrionVectors-XcodeIssue

Fix for extension registrations for different Resource types
This commit is contained in:
Brian Roberts 2026-06-07 18:18:30 -05:00 committed by GitHub
commit 059417e593
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 46 additions and 32 deletions

View file

@ -38,8 +38,13 @@ using namespace Torque;
const U32 GBitmap::csFileVersion = 3; 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() GBitmap::GBitmap()
: mInternalFormat(GFXFormatR8G8B8), : mInternalFormat(GFXFormatR8G8B8),
@ -198,24 +203,24 @@ U32 GBitmap::getFormatBytesPerPixel(GFXFormat fmt)
void GBitmap::sRegisterFormat( const GBitmap::Registration &reg ) void GBitmap::sRegisterFormat( const GBitmap::Registration &reg )
{ {
U32 insert = sRegistrations.size(); U32 insert = GBitmap::getRegistrations().size();
for ( U32 i = 0; i < sRegistrations.size(); i++ ) for ( U32 i = 0; i < GBitmap::getRegistrations().size(); i++ )
{ {
if ( sRegistrations[i].priority <= reg.priority ) if ( GBitmap::getRegistrations()[i].priority <= reg.priority )
{ {
insert = i; insert = i;
break; break;
} }
} }
sRegistrations.insert( insert, reg ); GBitmap::getRegistrations().insert( insert, reg );
} }
const GBitmap::Registration *GBitmap::sFindRegInfo( const String &extension ) 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 &reg = GBitmap::sRegistrations[i]; const GBitmap::Registration &reg = GBitmap::getRegistrations()[i];
const Vector<String> &extensions = reg.extensions; const Vector<String> &extensions = reg.extensions;
for ( U32 j = 0; j < extensions.size(); ++j ) for ( U32 j = 0; j < extensions.size(); ++j )
@ -236,9 +241,9 @@ bool GBitmap::sFindFile( const Path &path, Path *outPath )
Path tryPath( path ); Path tryPath( path );
for ( U32 i = 0; i < sRegistrations.size(); i++ ) for ( U32 i = 0; i < GBitmap::getRegistrations().size(); i++ )
{ {
const Registration &reg = sRegistrations[i]; const Registration &reg = GBitmap::getRegistrations()[i];
const Vector<String> &extensions = reg.extensions; const Vector<String> &extensions = reg.extensions;
for ( U32 j = 0; j < extensions.size(); ++j ) for ( U32 j = 0; j < extensions.size(); ++j )
@ -266,9 +271,9 @@ bool GBitmap::sFindFiles( const Path &path, Vector<Path> *outFoundPaths )
Path tryPath( path ); Path tryPath( path );
for ( U32 i = 0; i < GBitmap::sRegistrations.size(); i++ ) for ( U32 i = 0; i < GBitmap::getRegistrations().size(); i++ )
{ {
const GBitmap::Registration &reg = GBitmap::sRegistrations[i]; const GBitmap::Registration &reg = GBitmap::getRegistrations()[i];
const Vector<String> &extensions = reg.extensions; const Vector<String> &extensions = reg.extensions;
for ( U32 j = 0; j < extensions.size(); ++j ) for ( U32 j = 0; j < extensions.size(); ++j )
@ -292,9 +297,9 @@ String GBitmap::sGetExtensionList()
{ {
String list; String list;
for ( U32 i = 0; i < sRegistrations.size(); i++ ) for ( U32 i = 0; i < GBitmap::getRegistrations().size(); i++ )
{ {
const Registration &reg = sRegistrations[i]; const Registration &reg = GBitmap::getRegistrations()[i];
for ( U32 j = 0; j < reg.extensions.size(); j++ ) for ( U32 j = 0; j < reg.extensions.size(); j++ )
{ {
list += reg.extensions[j]; list += reg.extensions[j];

View file

@ -278,7 +278,7 @@ public:
template<class T, dsize_t mapLength> template<class T, dsize_t mapLength>
void swizzle(const Swizzle<T,mapLength> *s); void swizzle(const Swizzle<T,mapLength> *s);
static Vector<Registration> sRegistrations; static Vector<Registration>& getRegistrations();
private: private:
GFXFormat mInternalFormat; GFXFormat mInternalFormat;

View file

@ -858,14 +858,14 @@ Torque::Path GFXTextureManager::validatePath(const Torque::Path &path)
// Now loop through the rest of the GBitmap extensions // Now loop through the rest of the GBitmap extensions
// to see if we have any matches // 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) // If we have gotten a match (either in this loop or before)
// then we can exit // then we can exit
if (textureExt) if (textureExt)
break; break;
const GBitmap::Registration &reg = GBitmap::sRegistrations[i]; const GBitmap::Registration &reg = GBitmap::getRegistrations()[i];
const Vector<String> &extensions = reg.extensions; const Vector<String> &extensions = reg.extensions;
for (U32 j = 0; j < extensions.size(); ++j) for (U32 j = 0; j < extensions.size(); ++j)

View file

@ -407,9 +407,9 @@ void ColladaShapeLoader::computeBounds(Box3F& bounds)
String findTextureExtension(const Torque::Path &texPath) String findTextureExtension(const Torque::Path &texPath)
{ {
Torque::Path 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 &reg = GBitmap::sRegistrations[i]; GBitmap::Registration &reg = GBitmap::getRegistrations()[i];
for(S32 j = 0;j < reg.extensions.size();++j) for(S32 j = 0;j < reg.extensions.size();++j)
{ {
path.setExtension(reg.extensions[j]); path.setExtension(reg.extensions[j]);

View file

@ -1302,9 +1302,9 @@ String TSShapeLoader::getFormatExtensions()
{ {
// "*.dsq TAB *.dae TAB // "*.dsq TAB *.dae TAB
StringBuilder output; 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++) for (U32 i = 0; i < reg.extensions.size(); i++)
{ {
TSShape::ShapeFormat format = reg.extensions[i]; TSShape::ShapeFormat format = reg.extensions[i];
@ -1320,9 +1320,9 @@ String TSShapeLoader::getFormatFilters()
{ {
// "DSQ Files|*.dsq|COLLADA Files|*.dae|" // "DSQ Files|*.dsq|COLLADA Files|*.dae|"
StringBuilder output; 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++) for (U32 i = 0; i < reg.extensions.size(); i++)
{ {
TSShape::ShapeFormat format = reg.extensions[i]; TSShape::ShapeFormat format = reg.extensions[i];

View file

@ -38,19 +38,28 @@
#include "core/stream/fileStream.h" #include "core/stream/fileStream.h"
#include "core/fileObject.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) void TSShape::sRegisterFormat(const ShapeRegistration& reg)
{ {
U32 insert = sRegistrations.size(); U32 insert = TSShape::getRegistrations().size();
sRegistrations.insert(insert, reg); 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; const Vector<ShapeFormat>& extensions = exporting ? reg.export_extensions : reg.extensions;
for (U32 j = 0; j < extensions.size(); j++) for (U32 j = 0; j < extensions.size(); j++)
@ -2358,7 +2367,7 @@ template<> void *Resource<TSShape>::create(const Torque::Path &path)
} }
else else
{ {
const TSShape::ShapeRegistration* regInfo = TSShape::sFindRegInfo(extension); const TSShape::ShapeRegistration* regInfo = TSShape::sFindShapeRegInfo(extension);
if (regInfo == NULL) if (regInfo == NULL)
{ {
readSuccess = false; readSuccess = false;

View file

@ -122,8 +122,8 @@ public:
}; };
static void sRegisterFormat(const ShapeRegistration& reg); static void sRegisterFormat(const ShapeRegistration& reg);
static const ShapeRegistration* sFindRegInfo(const String& extension, bool exporting = false); static const ShapeRegistration* sFindShapeRegInfo(const String& extension, bool exporting = false);
static Vector<ShapeRegistration> sRegistrations; static Vector<ShapeRegistration>& getRegistrations();
/// Nodes hold the transforms in the shape's tree. They are the bones of the skeleton. /// Nodes hold the transforms in the shape's tree. They are the bones of the skeleton.
struct Node struct Node

View file

@ -1361,7 +1361,7 @@ bool TSShape::isShapeFileType(Torque::Path filePath)
{ {
String fileExt = filePath.getExtension(); String fileExt = filePath.getExtension();
if (TSShape::sFindRegInfo(fileExt)) if (TSShape::sFindShapeRegInfo(fileExt))
return true; return true;
return false; return false;