Merge pull request #1452 from marauder2k9-torque/MEMORY-MANAGER-REFACTOR

Memory Manager Refactor
This commit is contained in:
Brian Roberts 2025-05-12 15:31:06 -05:00 committed by GitHub
commit 6cda97867c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 581 additions and 1811 deletions

View file

@ -516,7 +516,12 @@ if (m##name##AssetId[index] != StringTable->EmptyString())\
else Con::warnf("Warning: %s::LOAD_SOUNDASSET_ARRAY(%s[%i])-%s", mClassName, m##name##AssetId[index], index, ImageAsset::getAssetErrstrn(assetState).c_str());\ else Con::warnf("Warning: %s::LOAD_SOUNDASSET_ARRAY(%s[%i])-%s", mClassName, m##name##AssetId[index], index, ImageAsset::getAssetErrstrn(assetState).c_str());\
} }
#define assetEnumNameConcat(x,suff)(new std::string( x + std::string(#suff)))->c_str() #define assetEnumNameConcat(x, suff) ([](const char* base) { \
String result = String(base) + #suff; \
char* ret = Con::getReturnBuffer(result.length() + 1); \
dStrcpy(ret, result.c_str(), result.length() + 1); \
return ret; \
})(x)
#define INITPERSISTFIELD_SOUNDASSET_ENUMED(name, enumType, maxValue, consoleClass, docs) \ #define INITPERSISTFIELD_SOUNDASSET_ENUMED(name, enumType, maxValue, consoleClass, docs) \
for (U32 i = 0; i < maxValue; i++)\ for (U32 i = 0; i < maxValue; i++)\

View file

@ -114,29 +114,6 @@ namespace engineAPI
} }
// The following are some tricks to make the memory leak checker run after global
// dtors have executed by placing some code in the termination segments.
#if defined( TORQUE_DEBUG ) && !defined( TORQUE_DISABLE_MEMORY_MANAGER )
#ifdef TORQUE_COMPILER_VISUALC
# pragma data_seg( ".CRT$XTU" )
static void* sCheckMemBeforeTermination = &Memory::ensureAllFreed;
# pragma data_seg()
#elif defined( TORQUE_COMPILER_GCC )
__attribute__ ( ( destructor ) ) static void _ensureAllFreed()
{
Memory::ensureAllFreed();
}
#endif
#endif
// Process a time event and update all sub-processes // Process a time event and update all sub-processes
void processTimeEvent(S32 elapsedTime) void processTimeEvent(S32 elapsedTime)
{ {
@ -216,10 +193,6 @@ void StandardMainLoop::init()
gStartupTimer = PlatformTimer::create(); gStartupTimer = PlatformTimer::create();
#endif #endif
#ifdef TORQUE_DEBUG_GUARD
Memory::flagCurrentAllocs( Memory::FLAG_Global );
#endif
Platform::setMathControlStateKnown(); Platform::setMathControlStateKnown();
// Asserts should be created FIRST // Asserts should be created FIRST
@ -327,10 +300,6 @@ void StandardMainLoop::init()
// Hook in for UDP notification // Hook in for UDP notification
Net::getPacketReceiveEvent().notify(GNet, &NetInterface::processPacketReceiveEvent); Net::getPacketReceiveEvent().notify(GNet, &NetInterface::processPacketReceiveEvent);
#ifdef TORQUE_DEBUG_GUARD
Memory::flagCurrentAllocs( Memory::FLAG_Static );
#endif
} }
void StandardMainLoop::shutdown() void StandardMainLoop::shutdown()
@ -378,9 +347,6 @@ void StandardMainLoop::shutdown()
// asserts should be destroyed LAST // asserts should be destroyed LAST
PlatformAssert::destroy(); PlatformAssert::destroy();
#if defined( TORQUE_DEBUG ) && !defined( TORQUE_DISABLE_MEMORY_MANAGER )
Memory::validate();
#endif
} }
void StandardMainLoop::preShutdown() void StandardMainLoop::preShutdown()

View file

@ -119,6 +119,18 @@ void AssetManager::onRemove()
mAssetTagsManifest->deleteObject(); mAssetTagsManifest->deleteObject();
} }
purgeAssets();
for (auto itr = mDeclaredAssets.begin(); itr != mDeclaredAssets.end(); ++itr)
{
delete itr->value;
}
mDeclaredAssets.clear();
// Clear dependency graphs
mAssetDependsOn.clear();
mAssetIsDependedOn.clear();
// Call parent. // Call parent.
Parent::onRemove(); Parent::onRemove();
} }

View file

@ -71,7 +71,7 @@ char* ConsoleValue::convertToBuffer() const
const char* ConsoleValue::getConsoleData() const const char* ConsoleValue::getConsoleData() const
{ {
return Con::getData(ct->consoleType, ct->dataPtr, 0, ct->enumTable); return Con::getData(type, dataPtr, 0, enumTable);
} }
ConsoleDocFragment* ConsoleDocFragment::smFirst; ConsoleDocFragment* ConsoleDocFragment::smFirst;
@ -427,20 +427,6 @@ void init()
smConsoleInput.notify(postConsoleInput); smConsoleInput.notify(postConsoleInput);
} }
//--------------------------------------
void shutdown()
{
AssertFatal(active == true, "Con::shutdown should only be called once.");
active = false;
smConsoleInput.remove(postConsoleInput);
consoleLogFile.close();
Namespace::shutdown();
AbstractClassRep::shutdown();
Compiler::freeConsoleParserList();
}
bool isActive() bool isActive()
{ {
@ -1201,10 +1187,10 @@ ConsoleValue _internalExecute(S32 argc, ConsoleValue argv[])
warnf(ConsoleLogEntry::Script, "%s: Unknown command.", funcName); warnf(ConsoleLogEntry::Script, "%s: Unknown command.", funcName);
STR.clearFunctionOffset(); STR.clearFunctionOffset();
return std::move(ConsoleValue()); return (ConsoleValue());
} }
return std::move(ent->execute(argc, argv, NULL)); return (ent->execute(argc, argv, NULL));
} }
ConsoleValue execute(S32 argc, ConsoleValue argv[]) ConsoleValue execute(S32 argc, ConsoleValue argv[])
@ -1234,7 +1220,7 @@ ConsoleValue execute(S32 argc, const char *argv[])
ConsoleStackFrameSaver stackSaver; ConsoleStackFrameSaver stackSaver;
stackSaver.save(); stackSaver.save();
StringArrayToConsoleValueWrapper args(argc, argv); StringArrayToConsoleValueWrapper args(argc, argv);
return std::move(execute(args.count(), args)); return (execute(args.count(), args));
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -1243,12 +1229,12 @@ ConsoleValue execute(S32 argc, const char *argv[])
static ConsoleValue _internalExecute(SimObject *object, S32 argc, ConsoleValue argv[], bool thisCallOnly) static ConsoleValue _internalExecute(SimObject *object, S32 argc, ConsoleValue argv[], bool thisCallOnly)
{ {
if (object == NULL) if (object == NULL)
return std::move(ConsoleValue()); return (ConsoleValue());
if(argc < 2) if(argc < 2)
{ {
STR.clearFunctionOffset(); STR.clearFunctionOffset();
return std::move(ConsoleValue()); return (ConsoleValue());
} }
// [neo, 10/05/2007 - #3010] // [neo, 10/05/2007 - #3010]
@ -1276,7 +1262,7 @@ static ConsoleValue _internalExecute(SimObject *object, S32 argc, ConsoleValue a
{ {
//warnf(ConsoleLogEntry::Script, "%s: undefined for object '%s' - id %d", funcName, object->getName(), object->getId()); //warnf(ConsoleLogEntry::Script, "%s: undefined for object '%s' - id %d", funcName, object->getName(), object->getId());
STR.clearFunctionOffset(); STR.clearFunctionOffset();
return std::move(ConsoleValue()); return (ConsoleValue());
} }
const char* oldIdent = dStrdup(argv[1].getString()); const char* oldIdent = dStrdup(argv[1].getString());
@ -1284,7 +1270,7 @@ static ConsoleValue _internalExecute(SimObject *object, S32 argc, ConsoleValue a
// Twiddle %this argument // Twiddle %this argument
argv[1].setInt(ident); argv[1].setInt(ident);
ConsoleValue ret = std::move(ent->execute(argc, argv, object)); ConsoleValue ret = (ent->execute(argc, argv, object));
// Twiddle it back // Twiddle it back
argv[1].setString(oldIdent); argv[1].setString(oldIdent);
@ -1295,7 +1281,7 @@ static ConsoleValue _internalExecute(SimObject *object, S32 argc, ConsoleValue a
warnf(ConsoleLogEntry::Script, "Con::execute - %d has no namespace: %s", object->getId(), funcName); warnf(ConsoleLogEntry::Script, "Con::execute - %d has no namespace: %s", object->getId(), funcName);
STR.clearFunctionOffset(); STR.clearFunctionOffset();
return std::move(ConsoleValue()); return (ConsoleValue());
} }
ConsoleValue execute(SimObject *object, S32 argc, ConsoleValue argv[], bool thisCallOnly) ConsoleValue execute(SimObject *object, S32 argc, ConsoleValue argv[], bool thisCallOnly)
@ -1303,7 +1289,7 @@ ConsoleValue execute(SimObject *object, S32 argc, ConsoleValue argv[], bool this
if(argc < 2) if(argc < 2)
{ {
STR.clearFunctionOffset(); STR.clearFunctionOffset();
return std::move(ConsoleValue()); return (ConsoleValue());
} }
ConsoleStackFrameSaver stackSaver; ConsoleStackFrameSaver stackSaver;
@ -1313,7 +1299,7 @@ ConsoleValue execute(SimObject *object, S32 argc, ConsoleValue argv[], bool this
{ {
if (isMainThread()) if (isMainThread())
{ {
return std::move(_internalExecute(object, argc, argv, thisCallOnly)); return (_internalExecute(object, argc, argv, thisCallOnly));
} }
else else
{ {
@ -1325,7 +1311,7 @@ ConsoleValue execute(SimObject *object, S32 argc, ConsoleValue argv[], bool this
warnf(ConsoleLogEntry::Script, "Con::execute - %d has no namespace: %s", object->getId(), argv[0].getString()); warnf(ConsoleLogEntry::Script, "Con::execute - %d has no namespace: %s", object->getId(), argv[0].getString());
STR.clearFunctionOffset(); STR.clearFunctionOffset();
return std::move(ConsoleValue()); return (ConsoleValue());
} }
ConsoleValue execute(SimObject *object, S32 argc, const char *argv[], bool thisCallOnly) ConsoleValue execute(SimObject *object, S32 argc, const char *argv[], bool thisCallOnly)
@ -1333,7 +1319,7 @@ ConsoleValue execute(SimObject *object, S32 argc, const char *argv[], bool thisC
ConsoleStackFrameSaver stackSaver; ConsoleStackFrameSaver stackSaver;
stackSaver.save(); stackSaver.save();
StringArrayToConsoleValueWrapper args(argc, argv); StringArrayToConsoleValueWrapper args(argc, argv);
return std::move(execute(object, args.count(), args, thisCallOnly)); return (execute(object, args.count(), args, thisCallOnly));
} }
inline ConsoleValue _executef(SimObject *obj, S32 checkArgc, S32 argc, ConsoleValue *argv) inline ConsoleValue _executef(SimObject *obj, S32 checkArgc, S32 argc, ConsoleValue *argv)
@ -1341,7 +1327,7 @@ inline ConsoleValue _executef(SimObject *obj, S32 checkArgc, S32 argc, ConsoleVa
const U32 maxArg = 12; const U32 maxArg = 12;
AssertFatal(checkArgc == argc, "Incorrect arg count passed to Con::executef(SimObject*)"); AssertFatal(checkArgc == argc, "Incorrect arg count passed to Con::executef(SimObject*)");
AssertFatal(argc <= maxArg - 1, "Too many args passed to Con::_executef(SimObject*). Please update the function to handle more."); AssertFatal(argc <= maxArg - 1, "Too many args passed to Con::_executef(SimObject*). Please update the function to handle more.");
return std::move(execute(obj, argc, argv)); return (execute(obj, argc, argv));
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -1350,7 +1336,7 @@ inline ConsoleValue _executef(S32 checkArgc, S32 argc, ConsoleValue *argv)
const U32 maxArg = 10; const U32 maxArg = 10;
AssertFatal(checkArgc == argc, "Incorrect arg count passed to Con::executef()"); AssertFatal(checkArgc == argc, "Incorrect arg count passed to Con::executef()");
AssertFatal(argc <= maxArg, "Too many args passed to Con::_executef(). Please update the function to handle more."); AssertFatal(argc <= maxArg, "Too many args passed to Con::_executef(). Please update the function to handle more.");
return std::move(execute(argc, argv)); return (execute(argc, argv));
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -2110,6 +2096,23 @@ void ensureTrailingSlash(char* pDstPath, const char* pSrcPath, S32 dstSize)
pDstPath[trailIndex] = 0; pDstPath[trailIndex] = 0;
} }
//--------------------------------------
void shutdown()
{
AssertFatal(active == true, "Con::shutdown should only be called once.");
active = false;
smConsoleInput.remove(postConsoleInput);
consoleLogFile.close();
Namespace::shutdown();
AbstractClassRep::shutdown();
Compiler::freeConsoleParserList();
gGlobalVars.reset();
PathExpandos.clear();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
StringTableEntry getDSOPath(const char *scriptPath) StringTableEntry getDSOPath(const char *scriptPath)
@ -2309,10 +2312,10 @@ ConsoleValue _BaseEngineConsoleCallbackHelper::_exec()
STR.clearFunctionOffset(); STR.clearFunctionOffset();
mArgc = mInitialArgc; // reset mArgc = mInitialArgc; // reset
return std::move(ConsoleValue()); return (ConsoleValue());
} }
ConsoleValue returnValue = std::move(Con::_internalExecute( mArgc, mArgv )); ConsoleValue returnValue = (Con::_internalExecute( mArgc, mArgv ));
mArgc = mInitialArgc; // reset args mArgc = mInitialArgc; // reset args
return returnValue; return returnValue;
} }
@ -2321,7 +2324,7 @@ ConsoleValue _BaseEngineConsoleCallbackHelper::_execLater(SimConsoleThreadExecEv
{ {
mArgc = mInitialArgc; // reset args mArgc = mInitialArgc; // reset args
Sim::postEvent((SimObject*)Sim::getRootGroup(), evt, Sim::getCurrentTime()); Sim::postEvent((SimObject*)Sim::getRootGroup(), evt, Sim::getCurrentTime());
return std::move(evt->getCB().waitForResult()); return (evt->getCB().waitForResult());
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View file

@ -37,6 +37,7 @@
#include "core/util/str.h" #include "core/util/str.h"
#include "core/util/journal/journaledSignal.h" #include "core/util/journal/journaledSignal.h"
#include "core/stringTable.h" #include "core/stringTable.h"
#include <iostream>
class SimObject; class SimObject;
class Namespace; class Namespace;
@ -119,6 +120,7 @@ typedef const char *StringTableEntry;
enum ConsoleValueType enum ConsoleValueType
{ {
cvNULL = -5,
cvInteger = -4, cvInteger = -4,
cvFloat = -3, cvFloat = -3,
cvString = -2, cvString = -2,
@ -126,93 +128,109 @@ enum ConsoleValueType
cvConsoleValueType = 0 cvConsoleValueType = 0
}; };
struct ConsoleValueConsoleType
{
S32 consoleType;
void* dataPtr;
EnumTable* enumTable;
};
class ConsoleValue class ConsoleValue
{ {
public:
#pragma warning( push )
#pragma warning( disable : 4201 ) // warning C4201: nonstandard extension used : nameless struct/union
union union
{ {
F64 f; struct
S64 i; {
char* s; F64 f;
void* data; S64 i;
ConsoleValueConsoleType* ct; char* s;
};
struct
{
void* dataPtr;
EnumTable* enumTable;
};
}; };
S32 type; S32 type;
U32 bufferLen;
static DataChunker sConversionAllocator; static DataChunker sConversionAllocator;
char* convertToBuffer() const; char* convertToBuffer() const;
TORQUE_FORCEINLINE bool hasAllocatedData() const
{
return (type == ConsoleValueType::cvString || isConsoleType()) && data != NULL;
}
const char* getConsoleData() const; const char* getConsoleData() const;
TORQUE_FORCEINLINE void cleanupData() TORQUE_FORCEINLINE void cleanupData()
{ {
if (hasAllocatedData()) if (type <= cvString && bufferLen > 0)
{ {
dFree(data); dFree(s);
data = NULL; bufferLen = 0;
}
}
TORQUE_FORCEINLINE void _move(ConsoleValue&& ref) noexcept
{
type = ref.type;
switch (ref.type)
{
case cvInteger:
i = ref.i;
break;
case cvFloat:
f = ref.f;
break;
case cvSTEntry:
TORQUE_CASE_FALLTHROUGH;
case cvString:
s = ref.s;
break;
default:
data = ref.data;
break;
} }
ref.data = NULL; s = const_cast<char*>(StringTable->EmptyString());
ref.setEmptyString(); type = ConsoleValueType::cvNULL;
} }
public:
ConsoleValue() ConsoleValue()
{ {
type = ConsoleValueType::cvSTEntry; type = ConsoleValueType::cvSTEntry;
s = const_cast<char*>(StringTable->EmptyString()); s = const_cast<char*>(StringTable->EmptyString());
bufferLen = 0;
} }
ConsoleValue(ConsoleValue&& ref) noexcept ConsoleValue(const ConsoleValue& ref)
{ {
_move(std::move(ref)); type = ConsoleValueType::cvSTEntry;
s = const_cast<char*>(StringTable->EmptyString());
bufferLen = 0;
switch (ref.type)
{
case cvNULL:
std::cout << "Ref already cleared!";
break;
case cvInteger:
setInt(ref.i);
break;
case cvFloat:
setFloat(ref.f);
break;
case cvSTEntry:
setStringTableEntry(ref.s);
break;
case cvString:
setString(ref.s);
break;
default:
setConsoleData(ref.type, ref.dataPtr, ref.enumTable);
break;
}
} }
TORQUE_FORCEINLINE ConsoleValue& operator=(ConsoleValue&& ref) noexcept ConsoleValue& operator=(const ConsoleValue& ref)
{ {
_move(std::move(ref)); switch (ref.type)
{
case cvNULL:
std::cout << "Ref already cleared!";
break;
case cvInteger:
setInt(ref.i);
break;
case cvFloat:
setFloat(ref.f);
break;
case cvSTEntry:
setStringTableEntry(ref.s);
break;
case cvString:
setString(ref.s);
break;
default:
setConsoleData(ref.type, ref.dataPtr, ref.enumTable);
break;
}
return *this; return *this;
} }
ConsoleValue(const ConsoleValue&) = delete;
ConsoleValue& operator=(const ConsoleValue&) = delete;
TORQUE_FORCEINLINE ~ConsoleValue() TORQUE_FORCEINLINE ~ConsoleValue()
{ {
cleanupData(); cleanupData();
@ -308,16 +326,19 @@ public:
type = ConsoleValueType::cvString; type = ConsoleValueType::cvString;
s = (char*)dMalloc(static_cast<dsize_t>(len) + 1); s = (char*)dMalloc(len + 1);
bufferLen = len + 1;
s[len] = '\0'; s[len] = '\0';
dStrcpy(s, val, static_cast<dsize_t>(len) + 1); dStrcpy(s, val, len + 1);
} }
TORQUE_FORCEINLINE void setStringRef(const char* ref, S32 len) TORQUE_FORCEINLINE void setStringRef(const char* ref, S32 len)
{ {
cleanupData(); cleanupData();
type = ConsoleValueType::cvString; type = ConsoleValueType::cvString;
s = const_cast<char*>(ref); s = (char*)std::move(ref);
bufferLen = len;
} }
TORQUE_FORCEINLINE void setBool(const bool val) TORQUE_FORCEINLINE void setBool(const bool val)
@ -331,7 +352,8 @@ public:
{ {
cleanupData(); cleanupData();
type = ConsoleValueType::cvSTEntry; type = ConsoleValueType::cvSTEntry;
s = const_cast<char*>(val); s = (char*)std::move(val);
bufferLen = 0;
} }
TORQUE_FORCEINLINE void setEmptyString() TORQUE_FORCEINLINE void setEmptyString()
@ -339,12 +361,13 @@ public:
setStringTableEntry(StringTable->EmptyString()); setStringTableEntry(StringTable->EmptyString());
} }
TORQUE_FORCEINLINE void setConsoleData(S32 consoleType, void* dataPtr, const EnumTable* enumTable) TORQUE_FORCEINLINE void setConsoleData(S32 inConsoleType, void* inDataPtr, const EnumTable* inEnumTable)
{ {
cleanupData(); cleanupData();
type = ConsoleValueType::cvConsoleValueType; type = inConsoleType;
ct = new ConsoleValueConsoleType{ consoleType, dataPtr, const_cast<EnumTable*>(enumTable) }; dataPtr = inDataPtr;
} enumTable = const_cast<EnumTable*>(inEnumTable);
};
TORQUE_FORCEINLINE S32 getType() const TORQUE_FORCEINLINE S32 getType() const
{ {
@ -366,11 +389,11 @@ public:
return type >= ConsoleValueType::cvConsoleValueType; return type >= ConsoleValueType::cvConsoleValueType;
} }
TORQUE_FORCEINLINE ConsoleValueConsoleType* getConsoleType() const TORQUE_FORCEINLINE S32 getConsoleType() const
{ {
if(type >= ConsoleValueType::cvConsoleValueType) if(type >= ConsoleValueType::cvConsoleValueType)
{ {
return ct; return type;
} }
else else
{ {
@ -1022,7 +1045,7 @@ namespace Con
ConsoleValue executef(R r, ArgTs ...argTs) ConsoleValue executef(R r, ArgTs ...argTs)
{ {
_EngineConsoleExecCallbackHelper<R> callback(r); _EngineConsoleExecCallbackHelper<R> callback(r);
return std::move(callback.template call<ConsoleValue>(argTs...)); return (callback.template call<ConsoleValue>(argTs...));
} }
/// } /// }
}; };

View file

@ -924,6 +924,12 @@ void Namespace::shutdown()
for (Namespace *walk = mNamespaceList; walk; walk = walk->mNext) for (Namespace *walk = mNamespaceList; walk; walk = walk->mNext)
walk->~Namespace(); walk->~Namespace();
gNamespaceCache.clear();
mNamespaceList = nullptr;
mGlobalNamespace = nullptr;
mAllocator.freeBlocks();
} }
void Namespace::trashCache() void Namespace::trashCache()
@ -1153,11 +1159,11 @@ ConsoleValue Namespace::Entry::execute(S32 argc, ConsoleValue *argv, SimObject *
{ {
if (mFunctionOffset) if (mFunctionOffset)
{ {
return std::move(mModule->exec(mFunctionOffset, argv[0].getString(), mNamespace, argc, argv, false, mPackage).value); return (mModule->exec(mFunctionOffset, argv[0].getString(), mNamespace, argc, argv, false, mPackage).value);
} }
else else
{ {
return std::move(ConsoleValue()); return (ConsoleValue());
} }
} }
@ -1167,7 +1173,7 @@ ConsoleValue Namespace::Entry::execute(S32 argc, ConsoleValue *argv, SimObject *
if (mToolOnly && !Con::isCurrentScriptToolScript()) if (mToolOnly && !Con::isCurrentScriptToolScript())
{ {
Con::errorf(ConsoleLogEntry::Script, "%s::%s - attempting to call tools only function from outside of tools", mNamespace->mName, mFunctionName); Con::errorf(ConsoleLogEntry::Script, "%s::%s - attempting to call tools only function from outside of tools", mNamespace->mName, mFunctionName);
return std::move(ConsoleValue()); return (ConsoleValue());
} }
#endif #endif
@ -1175,7 +1181,7 @@ ConsoleValue Namespace::Entry::execute(S32 argc, ConsoleValue *argv, SimObject *
{ {
Con::warnf(ConsoleLogEntry::Script, "%s::%s - wrong number of arguments. got %d, expected %d to %d", mNamespace->mName, mFunctionName, argc, mMinArgs, mMaxArgs); Con::warnf(ConsoleLogEntry::Script, "%s::%s - wrong number of arguments. got %d, expected %d to %d", mNamespace->mName, mFunctionName, argc, mMinArgs, mMaxArgs);
Con::warnf(ConsoleLogEntry::Script, "usage: %s", mUsage); Con::warnf(ConsoleLogEntry::Script, "usage: %s", mUsage);
return std::move(ConsoleValue()); return (ConsoleValue());
} }
ConsoleValue result; ConsoleValue result;

View file

@ -321,7 +321,7 @@ public:
void reset(); void reset();
inline ConsoleValue getValue() { return std::move(value); } inline ConsoleValue getValue() { return (value); }
inline U32 getIntValue() inline U32 getIntValue()
{ {
@ -349,8 +349,7 @@ public:
if (value.isConsoleType()) if (value.isConsoleType())
{ {
const char* dptr = Con::getData(TypeS32, &val, 0); const char* dptr = Con::getData(TypeS32, &val, 0);
ConsoleValueConsoleType* cvt = value.getConsoleType(); Con::setData(value.type, value.dataPtr, 0, 1, &dptr, value.enumTable);
Con::setData(cvt->consoleType, cvt->dataPtr, 0, 1, &dptr, cvt->enumTable);
} }
else else
{ {
@ -373,8 +372,7 @@ public:
if (value.isConsoleType()) if (value.isConsoleType())
{ {
const char* dptr = Con::getData(TypeF32, &val, 0); const char* dptr = Con::getData(TypeF32, &val, 0);
ConsoleValueConsoleType* cvt = value.getConsoleType(); Con::setData(value.type, value.dataPtr, 0, 1, &dptr, value.enumTable);
Con::setData(cvt->consoleType, cvt->dataPtr, 0, 1, &dptr, cvt->enumTable);
} }
else else
{ {
@ -397,8 +395,7 @@ public:
if (value.isConsoleType()) if (value.isConsoleType())
{ {
ConsoleValueConsoleType* cvt = value.getConsoleType(); Con::setData(value.type, value.dataPtr, 0, 1, &val, value.enumTable);
Con::setData(cvt->consoleType, cvt->dataPtr, 0, 1, &val, cvt->enumTable);
} }
else else
{ {

View file

@ -286,6 +286,12 @@ void AbstractClassRep::shutdown()
// Release storage allocated to the class table. // Release storage allocated to the class table.
for (auto walk = classLinkList; walk; walk = walk->nextClass)
{
walk->mFieldList.clear();
walk->mFieldList.compact(); // Important: frees the internal buffer
}
for (U32 group = 0; group < NetClassGroupsCount; group++) for (U32 group = 0; group < NetClassGroupsCount; group++)
for(U32 type = 0; type < NetClassTypesCount; type++) for(U32 type = 0; type < NetClassTypesCount; type++)
if( classTable[ group ][ type ] ) if( classTable[ group ][ type ] )

View file

@ -705,7 +705,9 @@ public:
smPropertyTable = _smPropertyTable; smPropertyTable = _smPropertyTable;
const_cast<EngineTypeInfo*>(mTypeInfo)->mPropertyTable = &_smPropertyTable; const_cast<EngineTypeInfo*>(mTypeInfo)->mPropertyTable = &_smPropertyTable;
// After we hand it off, immediately delete if safe:
delete[] props;
// Let the base finish up. // Let the base finish up.
AbstractClassRep::init(); AbstractClassRep::init();
} }

View file

@ -89,10 +89,10 @@ public:
stack.pop_back(); stack.pop_back();
} }
TORQUE_FORCEINLINE void push(ConsoleValue&& val) TORQUE_FORCEINLINE void push(ConsoleValue val)
{ {
Frame& frame = stack.last(); Frame& frame = stack.last();
frame.values[frame.internalCounter++] = std::move(val); frame.values[frame.internalCounter++] = (val);
} }
TORQUE_FORCEINLINE void argvc(StringTableEntry fn, S32& argc, ConsoleValue** argv) TORQUE_FORCEINLINE void argvc(StringTableEntry fn, S32& argc, ConsoleValue** argv)

View file

@ -148,7 +148,7 @@ static void dumpVariable( Stream& stream,
// Skip variables for which we can't decipher their type. // Skip variables for which we can't decipher their type.
ConsoleBaseType* type = ConsoleBaseType::getType( entry->value.getConsoleType()->consoleType ); ConsoleBaseType* type = ConsoleBaseType::getType( entry->value.type );
if( !type ) if( !type )
{ {
Con::errorf( "Can't find type for variable '%s'", entry->name ); Con::errorf( "Can't find type for variable '%s'", entry->name );

View file

@ -14,10 +14,10 @@ namespace Con
public: public:
EvalResult() {} EvalResult() {}
EvalResult(ConsoleValue&& pValue) EvalResult(ConsoleValue pValue)
{ {
valid = true; valid = true;
value = (ConsoleValue&&)pValue; value = (pValue);
} }
EvalResult(String errorMessage) EvalResult(String errorMessage)

View file

@ -16,7 +16,7 @@ namespace Con
gLastEvalResult.value.setString(pLastEvalResult.value.getString()); gLastEvalResult.value.setString(pLastEvalResult.value.getString());
return pLastEvalResult; return pLastEvalResult;
} }
inline EvalResult getLastEvalResult() { return setLastEvalResult(std::move(gLastEvalResult)); }; inline EvalResult getLastEvalResult() { return setLastEvalResult((gLastEvalResult)); };
bool runStream(Stream* byteCode, const char* fileName); bool runStream(Stream* byteCode, const char* fileName);

View file

@ -116,7 +116,7 @@ ConsoleValue SimConsoleThreadExecCallback::waitForResult()
{ {
if(sem->acquire(true)) if(sem->acquire(true))
{ {
return std::move(retVal); return (retVal);
} }
return ConsoleValue(); return ConsoleValue();
@ -134,9 +134,9 @@ void SimConsoleThreadExecEvent::process(SimObject* object)
if (cb) if (cb)
{ {
if (mOnObject) if (mOnObject)
cb->handleCallback(std::move(Con::execute(object, mArgc, mArgv))); cb->handleCallback(Con::execute(object, mArgc, mArgv));
else else
cb->handleCallback(std::move(Con::execute(mArgc, mArgv))); cb->handleCallback(Con::execute(mArgc, mArgv));
} }
else else
{ {

View file

@ -3536,15 +3536,13 @@ DefineEngineMethod( SimObject, getDebugInfo, ArrayObject*, (),,
array->push_back( "Flag|CanSave", object->getCanSave() ? "true" : "false" ); array->push_back( "Flag|CanSave", object->getCanSave() ? "true" : "false" );
#ifndef TORQUE_DISABLE_MEMORY_MANAGER #ifndef TORQUE_DISABLE_MEMORY_MANAGER
Memory::Info memInfo; Memory::MemInfo memInfo;
Memory::getMemoryInfo( object, memInfo ); Memory::getMemoryInfo( object, memInfo );
array->push_back( "Memory|AllocNumber", String::ToString( memInfo.mAllocNumber ) ); array->push_back( "Memory|AllocNumber", String::ToString( memInfo.allocId) );
array->push_back( "Memory|AllocSize", String::ToString( memInfo.mAllocSize ) ); array->push_back( "Memory|AllocSize", String::ToString( (U32)memInfo.size) );
array->push_back( "Memory|AllocFile", memInfo.mFileName ); array->push_back( "Memory|AllocFile", memInfo.file);
array->push_back( "Memory|AllocLine", String::ToString( memInfo.mLineNumber ) ); array->push_back( "Memory|AllocLine", String::ToString( memInfo.line) );
array->push_back( "Memory|IsGlobal", memInfo.mIsGlobal ? "true" : "false" );
array->push_back( "Memory|IsStatic", memInfo.mIsStatic ? "true" : "false" );
#endif #endif
return array; return array;

View file

@ -3363,7 +3363,7 @@ yyreport_syntax_error (const yypcontext_t *ctx)
output += String::ToString("%5s | %*s", "", loc->first_column, "^"); output += String::ToString("%5s | %*s", "", loc->first_column, "^");
} }
yyerror("%s",output.c_str()); yyerror("%s", output.c_str());
return ret; return ret;
} }

View file

@ -668,7 +668,7 @@ Con::EvalResult CodeBlock::compileExec(StringTableEntry fileName, const char *in
Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", codeSize, lastIp); Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", codeSize, lastIp);
// repurpose argc as local register counter for global state // repurpose argc as local register counter for global state
return std::move(exec(0, fileName, NULL, localRegisterCount, 0, noCalls, NULL, setFrame)); return (exec(0, fileName, NULL, localRegisterCount, 0, noCalls, NULL, setFrame));
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------

View file

@ -612,7 +612,7 @@ Con::EvalResult CodeBlock::exec(U32 ip, const char* functionName, Namespace* thi
{ {
S32 reg = code[ip + (2 + 6 + 1 + 1) + i]; S32 reg = code[ip + (2 + 6 + 1 + 1) + i];
ConsoleValue& value = argv[i + 1]; ConsoleValue& value = argv[i + 1];
Script::gEvalState.moveConsoleValue(reg, std::move(value)); Script::gEvalState.moveConsoleValue(reg, (value));
} }
ip = ip + fnArgc + (2 + 6 + 1 + 1); ip = ip + fnArgc + (2 + 6 + 1 + 1);
curFloatTable = functionFloats; curFloatTable = functionFloats;
@ -1214,7 +1214,7 @@ Con::EvalResult CodeBlock::exec(U32 ip, const char* functionName, Namespace* thi
case OP_RETURN: case OP_RETURN:
{ {
returnValue = std::move(stack[_STK]); returnValue = (stack[_STK]);
_STK--; _STK--;
// Clear iterator state. // Clear iterator state.
@ -1905,7 +1905,7 @@ Con::EvalResult CodeBlock::exec(U32 ip, const char* functionName, Namespace* thi
if (nsEntry->mFunctionOffset) if (nsEntry->mFunctionOffset)
{ {
ConsoleValue returnFromFn = nsEntry->mModule->exec(nsEntry->mFunctionOffset, fnName, nsEntry->mNamespace, callArgc, callArgv, false, nsEntry->mPackage).value; ConsoleValue returnFromFn = nsEntry->mModule->exec(nsEntry->mFunctionOffset, fnName, nsEntry->mNamespace, callArgc, callArgv, false, nsEntry->mPackage).value;
stack[_STK + 1] = std::move(returnFromFn); stack[_STK + 1] = (returnFromFn);
} }
else // no body else // no body
stack[_STK + 1].setEmptyString(); stack[_STK + 1].setEmptyString();
@ -2040,7 +2040,7 @@ Con::EvalResult CodeBlock::exec(U32 ip, const char* functionName, Namespace* thi
break; break;
case OP_PUSH: case OP_PUSH:
gCallStack.push(std::move(stack[_STK--])); gCallStack.push((stack[_STK--]));
break; break;
case OP_PUSH_FRAME: case OP_PUSH_FRAME:
@ -2303,7 +2303,7 @@ execFinished:
AssertFatal(!(_STK < stackStart), "String stack popped too much in script exec"); AssertFatal(!(_STK < stackStart), "String stack popped too much in script exec");
#endif #endif
return Con::EvalResult(std::move(returnValue)); return Con::EvalResult((returnValue));
} }
//------------------------------------------------------------ //------------------------------------------------------------

View file

@ -269,8 +269,10 @@ U32 CompilerStringTable::addFloatString(F64 value)
void CompilerStringTable::reset() void CompilerStringTable::reset()
{ {
list = NULL; // Reset list and associated variables
list = nullptr;
totalLen = 0; totalLen = 0;
hashTable.clear(); // Clear the lookup table too
} }
char *CompilerStringTable::build() char *CompilerStringTable::build()

View file

@ -1,4 +1,4 @@
#ifndef _EVALSTATE_H #ifndef _EVALSTATE_H
#define _EVALSTATE_H #define _EVALSTATE_H
#include "console/consoleInternal.h" #include "console/consoleInternal.h"
@ -83,7 +83,7 @@ public:
TORQUE_FORCEINLINE void moveConsoleValue(S32 reg, ConsoleValue val) TORQUE_FORCEINLINE void moveConsoleValue(S32 reg, ConsoleValue val)
{ {
currentRegisterArray->values[reg] = std::move(val); currentRegisterArray->values[reg] = (val);
} }
void pushFrame(StringTableEntry frameName, Namespace *ns, S32 regCount); void pushFrame(StringTableEntry frameName, Namespace *ns, S32 regCount);

View file

@ -39,7 +39,7 @@ namespace TorqueScript
fileName = StringTable->insert(fileName); fileName = StringTable->insert(fileName);
CodeBlock* newCodeBlock = new CodeBlock(); CodeBlock* newCodeBlock = new CodeBlock();
return std::move(newCodeBlock->compileExec(fileName, string, false, fileName ? -1 : 0)); return (newCodeBlock->compileExec(fileName, string, false, fileName ? -1 : 0));
} }
Con::EvalResult TorqueScriptRuntime::evaluate(const char* script, S32 frame, bool echo, const char* fileName) Con::EvalResult TorqueScriptRuntime::evaluate(const char* script, S32 frame, bool echo, const char* fileName)

View file

@ -289,6 +289,11 @@ UTF8* createUTF8string( const UTF16* unistring)
return ret; return ret;
} }
void UTF16ClearCache()
{
sgUTF16Cache.clear();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -66,6 +66,8 @@ UTF16* createUTF16string( const UTF8 *unistring);
UTF8* createUTF8string( const UTF16 *unistring); UTF8* createUTF8string( const UTF16 *unistring);
void UTF16ClearCache();
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/// Functions that convert buffers of unicode code points, into a provided buffer. /// Functions that convert buffers of unicode code points, into a provided buffer.
/// - These functions are useful for working on existing buffers. /// - These functions are useful for working on existing buffers.
@ -138,4 +140,4 @@ const UTF8* getNthCodepoint(const UTF8 *unistring, const U32 n);
bool chompUTF8BOM( const char *inString, char **outStringPtr ); bool chompUTF8BOM( const char *inString, char **outStringPtr );
bool isValidUTF8BOM( U8 bom[4] ); bool isValidUTF8BOM( U8 bom[4] );
#endif // _UNICODE_H_ #endif // _UNICODE_H_

View file

@ -193,7 +193,7 @@ private:
{ {
Node* mNext; Node* mNext;
Pair mPair; Pair mPair;
Node(): mNext(0) {} Node(): mNext(nullptr) {}
Node(Pair p,Node* n) Node(Pair p,Node* n)
: mNext(n), : mNext(n),
mPair(p) mPair(p)
@ -226,8 +226,8 @@ public:
_Iterator() _Iterator()
{ {
mHashTable = 0; mHashTable = nullptr;
mLink = 0; mLink = nullptr;
} }
_Iterator(M* table,E* ptr) _Iterator(M* table,E* ptr)
@ -320,7 +320,7 @@ public:
template<typename Key, typename Value> HashTable<Key,Value>::HashTable() : mNodeAllocator(512) template<typename Key, typename Value> HashTable<Key,Value>::HashTable() : mNodeAllocator(512)
{ {
mTableSize = 0; mTableSize = 0;
mTable = 0; mTable = nullptr;
mSize = 0; mSize = 0;
} }
@ -328,7 +328,7 @@ template<typename Key, typename Value> HashTable<Key,Value>::HashTable(const Has
{ {
mSize = 0; mSize = 0;
mTableSize = 0; mTableSize = 0;
mTable = 0; mTable = nullptr;
*this = p; *this = p;
} }
@ -357,7 +357,7 @@ typename HashTable<Key,Value>::Node* HashTable<Key,Value>::_next(U32 index) cons
for (; index < mTableSize; index++) for (; index < mTableSize; index++)
if (Node* node = mTable[index]) if (Node* node = mTable[index])
return node; return node;
return 0; return nullptr;
} }
template<typename Key, typename Value> template<typename Key, typename Value>
@ -402,7 +402,7 @@ void HashTable<Key,Value>::_destroy()
mNodeAllocator.freeBlocks(); mNodeAllocator.freeBlocks();
delete[] mTable; delete[] mTable;
mTable = NULL; mTable = nullptr;
} }
@ -509,7 +509,7 @@ typename HashTable<Key,Value>::Iterator HashTable<Key,Value>::insertEqual(const
template<typename Key, typename Value> template<typename Key, typename Value>
void HashTable<Key,Value>::erase(const Key& key) void HashTable<Key,Value>::erase(const Key& key)
{ {
if (mTable==NULL) if (mTable == nullptr)
return; return;
Node** prev = &mTable[_index(key)]; Node** prev = &mTable[_index(key)];
for (Node* itr = *prev; itr; prev = &itr->mNext, itr = itr->mNext) for (Node* itr = *prev; itr; prev = &itr->mNext, itr = itr->mNext)
@ -529,7 +529,7 @@ void HashTable<Key,Value>::erase(const Key& key)
template<typename Key, typename Value> template<typename Key, typename Value>
void HashTable<Key,Value>::erase(Iterator node) void HashTable<Key,Value>::erase(Iterator node)
{ {
if (mTable==NULL) if (mTable == nullptr)
return; return;
Node** prev = &mTable[_index(node->key)]; Node** prev = &mTable[_index(node->key)];
for (Node* itr = *prev; itr; prev = &itr->mNext, itr = itr->mNext) for (Node* itr = *prev; itr; prev = &itr->mNext, itr = itr->mNext)
@ -547,7 +547,7 @@ void HashTable<Key,Value>::erase(Iterator node)
template<typename Key, typename Value> template<typename Key, typename Value>
void HashTable<Key,Value>::erase(const Key & key, const Value & value) void HashTable<Key,Value>::erase(const Key & key, const Value & value)
{ {
if (mTable==NULL) if (mTable == nullptr)
return; return;
Node** prev = &mTable[_index(key)]; Node** prev = &mTable[_index(key)];
for (Node* itr = *prev; itr; prev = &itr->mNext, itr = itr->mNext) for (Node* itr = *prev; itr; prev = &itr->mNext, itr = itr->mNext)
@ -591,7 +591,7 @@ typename HashTable<Key,Value>::Iterator HashTable<Key,Value>::find(const Key& ke
for (Node* itr = mTable[_index(key)]; itr; itr = itr->mNext) for (Node* itr = mTable[_index(key)]; itr; itr = itr->mNext)
if ( KeyCmp::equals<Key>( itr->mPair.key, key ) ) if ( KeyCmp::equals<Key>( itr->mPair.key, key ) )
return Iterator(this,itr); return Iterator(this,itr);
return Iterator(this,0); return Iterator(this, nullptr);
} }
template<typename Key, typename Value> template<typename Key, typename Value>
@ -605,7 +605,7 @@ typename HashTable<Key,Value>::ConstIterator HashTable<Key,Value>::find(const Ke
return ConstIterator(this,itr); return ConstIterator(this,itr);
} }
} }
return ConstIterator(this,0); return ConstIterator(this, nullptr);
} }
template<typename Key, typename Value> template<typename Key, typename Value>
@ -659,13 +659,13 @@ inline typename HashTable<Key,Value>::ConstIterator HashTable<Key,Value>::begin(
template<typename Key, typename Value> template<typename Key, typename Value>
inline typename HashTable<Key,Value>::Iterator HashTable<Key,Value>::end() inline typename HashTable<Key,Value>::Iterator HashTable<Key,Value>::end()
{ {
return Iterator(this,0); return Iterator(this, nullptr);
} }
template<typename Key, typename Value> template<typename Key, typename Value>
inline typename HashTable<Key,Value>::ConstIterator HashTable<Key,Value>::end() const inline typename HashTable<Key,Value>::ConstIterator HashTable<Key,Value>::end() const
{ {
return ConstIterator(this,0); return ConstIterator(this, nullptr);
} }

View file

@ -205,6 +205,7 @@ int main(int argc, const char **argv)
#include "platform/platform.h" #include "platform/platform.h"
#include "app/mainLoop.h" #include "app/mainLoop.h"
#include "T3D/gameFunctions.h" #include "T3D/gameFunctions.h"
#include "platform/platformMemory.h"
#if defined(WIN32) || defined(_WIN32) #if defined(WIN32) || defined(_WIN32)
//tell switchable graphics supported systems that they need to use the beefier GPU //tell switchable graphics supported systems that they need to use the beefier GPU
@ -230,8 +231,9 @@ S32 TorqueMain(S32 argc, const char **argv)
// argv = argvFake; // argv = argvFake;
// } // }
// Memory::enableLogging("testMem.log"); #if defined( TORQUE_DEBUG ) && !defined(TORQUE_DISABLE_MEMORY_MANAGER)
// Memory::setBreakAlloc(104717); Memory::init();
#endif
// Initialize the subsystems. // Initialize the subsystems.
StandardMainLoop::init(); StandardMainLoop::init();
@ -254,6 +256,12 @@ S32 TorqueMain(S32 argc, const char **argv)
if( StandardMainLoop::requiresRestart() ) if( StandardMainLoop::requiresRestart() )
Platform::restartInstance(); Platform::restartInstance();
#if defined( TORQUE_DEBUG ) && !defined( TORQUE_DISABLE_MEMORY_MANAGER )
Memory::shutdown();
#endif
// Return. // Return.
return StandardMainLoop::getReturnStatus(); return StandardMainLoop::getReturnStatus();
} }

File diff suppressed because it is too large Load diff

View file

@ -27,33 +27,25 @@
namespace Memory namespace Memory
{ {
enum EFlag #if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
struct MemInfo
{ {
FLAG_Debug, void* ptr;
FLAG_Global, dsize_t size;
FLAG_Static const char* file;
U32 line;
U32 allocId;
bool flagged;
void* backtracePtrs[16];
int backtraceSize;
}; };
struct Info void init();
{ void shutdown();
U32 mAllocNumber; void getMemoryInfo(void* ptr, MemInfo& info);
U32 mAllocSize; void checkPtr(void* ptr);
const char* mFileName; #endif
U32 mLineNumber;
bool mIsArray;
bool mIsGlobal;
bool mIsStatic;
};
void checkPtr( void* ptr );
void flagCurrentAllocs( EFlag flag = FLAG_Debug );
void ensureAllFreed();
void dumpUnflaggedAllocs(const char *file, EFlag flag = FLAG_Debug );
S32 countUnflaggedAllocs(const char *file, S32 *outUnflaggedRealloc = NULL, EFlag flag = FLAG_Debug );
dsize_t getMemoryUsed();
dsize_t getMemoryAllocated();
void getMemoryInfo( void* ptr, Info& info );
void validate();
} }
#endif // _TORQUE_PLATFORM_PLATFORMMEMORY_H_ #endif // _TORQUE_PLATFORM_PLATFORMMEMORY_H_

View file

@ -317,6 +317,8 @@ void Platform::shutdown()
GFXDevice::destroy(); GFXDevice::destroy();
WinConsole::destroy(); WinConsole::destroy();
UTF16ClearCache();
} }
extern bool LinkConsoleFunctions; extern bool LinkConsoleFunctions;

View file

@ -922,7 +922,7 @@ void SceneZoneSpaceManager::verifyState()
AssertFatal( mObjectZoneLists.containsBinItem(object->mZoneListHandle, zoneId), "SceneZoneSpaceManager::verifyState - Object doesn't have zone in list!"); AssertFatal( mObjectZoneLists.containsBinItem(object->mZoneListHandle, zoneId), "SceneZoneSpaceManager::verifyState - Object doesn't have zone in list!");
#ifndef TORQUE_DISABLE_MEMORY_MANAGER #ifndef TORQUE_DISABLE_MEMORY_MANAGER
Memory::checkPtr( ref->object ); Memory::checkPtr( object );
#endif #endif
} }
} }

View file

@ -32,7 +32,8 @@
inline ConsoleValue RunScript(const char* str) inline ConsoleValue RunScript(const char* str)
{ {
return std::move(Con::evaluate(str, false, NULL).value); auto conRes = Con::evaluate(str, false, NULL);
return conRes.value;
} }
using ::testing::Matcher; using ::testing::Matcher;

View file

@ -29,12 +29,23 @@
#include "ts/tsMaterialList.h" #include "ts/tsMaterialList.h"
#include "core/stream/fileStream.h" #include "core/stream/fileStream.h"
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
#ifdef new
#undef new
#endif
#endif
// assimp include files. // assimp include files.
#include <assimp/cimport.h> #include <assimp/cimport.h>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/postprocess.h> #include <assimp/postprocess.h>
#include <assimp/types.h> #include <assimp/types.h>
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
# define _new new(__FILE__, __LINE__)
# define new _new
#endif
U32 AssimpAppMaterial::sDefaultMatNumber = 0; U32 AssimpAppMaterial::sDefaultMatNumber = 0;
String AppMaterial::cleanString(const String& str) String AppMaterial::cleanString(const String& str)

View file

@ -26,8 +26,20 @@
#ifndef _APPMATERIAL_H_ #ifndef _APPMATERIAL_H_
#include "ts/loader/appMaterial.h" #include "ts/loader/appMaterial.h"
#endif #endif
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
#ifdef new
#undef new
#endif
#endif
#include <assimp/scene.h> #include <assimp/scene.h>
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
# define _new new(__FILE__, __LINE__)
# define new _new
#endif
class Material; class Material;
class AssimpAppMaterial : public AppMaterial class AssimpAppMaterial : public AppMaterial

View file

@ -24,12 +24,24 @@
#include "ts/collada/colladaExtensions.h" #include "ts/collada/colladaExtensions.h"
#include "ts/assimp/assimpAppMesh.h" #include "ts/assimp/assimpAppMesh.h"
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
#ifdef new
#undef new
#endif
#endif
// assimp include files. // assimp include files.
#include <assimp/cimport.h> #include <assimp/cimport.h>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/postprocess.h> #include <assimp/postprocess.h>
#include <assimp/types.h> #include <assimp/types.h>
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
# define _new new(__FILE__, __LINE__)
# define new _new
#endif
bool AssimpAppMesh::fixedSizeEnabled = false; bool AssimpAppMesh::fixedSizeEnabled = false;
S32 AssimpAppMesh::fixedSize = 2; S32 AssimpAppMesh::fixedSize = 2;

View file

@ -25,12 +25,25 @@
#include "ts/assimp/assimpAppNode.h" #include "ts/assimp/assimpAppNode.h"
#include "ts/assimp/assimpAppMesh.h" #include "ts/assimp/assimpAppMesh.h"
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
#ifdef new
#undef new
#endif
#endif
// assimp include files. // assimp include files.
#include <assimp/cimport.h> #include <assimp/cimport.h>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/postprocess.h> #include <assimp/postprocess.h>
#include <assimp/types.h> #include <assimp/types.h>
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
# define _new new(__FILE__, __LINE__)
# define new _new
#endif
aiAnimation* AssimpAppNode::sActiveSequence = NULL; aiAnimation* AssimpAppNode::sActiveSequence = NULL;
F32 AssimpAppNode::sTimeMultiplier = 1.0f; F32 AssimpAppNode::sTimeMultiplier = 1.0f;

View file

@ -33,11 +33,23 @@
#include "ts/collada/colladaExtensions.h" #include "ts/collada/colladaExtensions.h"
#endif #endif
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
#ifdef new
#undef new
#endif
#endif
#ifndef AI_TYPES_H_INC #ifndef AI_TYPES_H_INC
#include <assimp/types.h> #include <assimp/types.h>
#endif #endif
#include <assimp/scene.h> #include <assimp/scene.h>
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
# define _new new(__FILE__, __LINE__)
# define new _new
#endif
class AssimpAppMesh; class AssimpAppMesh;
class AssimpAppNode : public AppNode class AssimpAppNode : public AppNode

View file

@ -18,8 +18,20 @@
#include "ts/loader/appSequence.h" #include "ts/loader/appSequence.h"
#endif #endif
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
#ifdef new
#undef new
#endif
#endif
#include <assimp/scene.h> #include <assimp/scene.h>
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
# define _new new(__FILE__, __LINE__)
# define new _new
#endif
class AssimpAppSequence : public AppSequence class AssimpAppSequence : public AppSequence
{ {
String mSequenceName; String mSequenceName;

View file

@ -51,6 +51,11 @@
#include "gfx/bitmap/gBitmap.h" #include "gfx/bitmap/gBitmap.h"
#include "gui/controls/guiTreeViewCtrl.h" #include "gui/controls/guiTreeViewCtrl.h"
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
#ifdef new
#undef new
#endif
#endif
// assimp include files. // assimp include files.
#include <assimp/cimport.h> #include <assimp/cimport.h>
#include <assimp/scene.h> #include <assimp/scene.h>
@ -59,6 +64,12 @@
#include <assimp/config.h> #include <assimp/config.h>
#include <exception> #include <exception>
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
# define _new new(__FILE__, __LINE__)
# define new _new
#endif
MODULE_BEGIN( AssimpShapeLoader ) MODULE_BEGIN( AssimpShapeLoader )
MODULE_INIT_AFTER( ShapeLoader ) MODULE_INIT_AFTER( ShapeLoader )
MODULE_INIT MODULE_INIT

View file

@ -55,6 +55,9 @@
/// Define me if you want to disable Torque memory manager. /// Define me if you want to disable Torque memory manager.
#cmakedefine TORQUE_DISABLE_MEMORY_MANAGER #cmakedefine TORQUE_DISABLE_MEMORY_MANAGER
#ifndef TORQUE_ENABLE_ASSERTS // disable memory manager when in release build.
#define TORQUE_DISABLE_MEMORY_MANAGER
#endif
/// Define me if you want to disable the virtual mount system. /// Define me if you want to disable the virtual mount system.
#cmakedefine TORQUE_DISABLE_VIRTUAL_MOUNT_SYSTEM #cmakedefine TORQUE_DISABLE_VIRTUAL_MOUNT_SYSTEM