Merge branch 'method_Unmangle' into PBR_PR

This commit is contained in:
Azaezel 2018-12-12 14:54:22 -06:00
commit 1eed979a9c
632 changed files with 3935 additions and 3450 deletions

View file

@ -536,80 +536,67 @@ float LinearColorF::sSrgbToLinear[256] =
#endif
//-----------------------------------------------------------------------------
ConsoleFunction( getStockColorCount, S32, 1, 1, "() - Gets a count of available stock colors.\n"
"@return A count of available stock colors." )
DefineEngineFunction(getStockColorCount, S32, (),,
"@brief Gets a count of available stock colors.\n"
"@return A count of available stock colors.")
{
return StockColor::getCount();
}
//-----------------------------------------------------------------------------
ConsoleFunction( getStockColorName, const char*, 2, 2, "(stockColorIndex) - Gets the stock color name at the specified index.\n"
DefineEngineFunction(getStockColorName, const char*, (S32 stockColorIndex),,
"@brief Gets the stock color name at the specified index.\n"
"@param stockColorIndex The zero-based index of the stock color name to retrieve.\n"
"@return The stock color name at the specified index or nothing if the string is invalid." )
"@return The stock color name at the specified index or nothing if the string is invalid.")
{
// Fetch stock color index.
const S32 stockColorIndex = dAtoi(argv[1]);
// Fetch the color item.
const StockColorItem* pColorItem = StockColor::getColorItem( stockColorIndex );
const StockColorItem* pColorItem = StockColor::getColorItem(stockColorIndex);
return pColorItem == NULL ? NULL : pColorItem->getColorName();
}
//-----------------------------------------------------------------------------
ConsoleFunction( isStockColor, bool, 2, 2, "(stockColorName) - Gets whether the specified name is a stock color or not.\n"
DefineEngineFunction(isStockColor, bool, (const char* stockColorName),,
"@brief Gets whether the specified name is a stock color or not.\n"
"@param stockColorName - The stock color name to test for.\n"
"@return Whether the specified name is a stock color or not.\n" )
"@return Whether the specified name is a stock color or not.\n")
{
// Fetch stock color name.
const char* pStockColorName = argv[1];
// Return whether this is a stock color name or not.
return StockColor::isColor( pStockColorName );
return StockColor::isColor(stockColorName);
}
//-----------------------------------------------------------------------------
ConsoleFunction( getStockColorF, const char*, 2, 2, "(stockColorName) - Gets a floating-point-based stock color by name.\n"
DefineEngineFunction(getStockColorF, LinearColorF, (const char* stockColorName),,
"@brief Gets a floating-point-based stock color by name.\n"
"@param stockColorName - The stock color name to retrieve.\n"
"@return The stock color that matches the specified color name. Returns nothing if the color name is not found.\n" )
"@return The stock color that matches the specified color name. Returns nothing if the color name is not found.\n")
{
// Fetch stock color name.
const char* pStockColorName = argv[1];
// Return nothing if stock color name is invalid.
if ( !StockColor::isColor( pStockColorName ) )
if (!StockColor::isColor(stockColorName))
return StringTable->EmptyString();
// Fetch stock color.
const LinearColorF& color = StockColor::colorF( pStockColorName );
const LinearColorF& color = StockColor::colorF(stockColorName);
// Format stock color.
char* returnBuffer = Con::getReturnBuffer(256);
dSprintf(returnBuffer, 256, "%g %g %g %g", color.red, color.green, color.blue, color.alpha);
return(returnBuffer);
return color;
}
//-----------------------------------------------------------------------------
ConsoleFunction( getStockColorI, const char*, 2, 2, "(stockColorName) - Gets a byte-based stock color by name.\n"
DefineEngineFunction(getStockColorI, ColorI, (const char* stockColorName),,
"@brief Gets a byte-based stock color by name.\n"
"@param stockColorName - The stock color name to retrieve.\n"
"@return The stock color that matches the specified color name. Returns nothing if the color name is not found.\n" )
"@return The stock color that matches the specified color name. Returns nothing if the color name is not found.\n")
{
// Fetch stock color name.
const char* pStockColorName = argv[1];
// Return nothing if stock color name is invalid.
if ( !StockColor::isColor( pStockColorName ) )
if (!StockColor::isColor(stockColorName))
return StringTable->EmptyString();
// Fetch stock color.
const ColorI& color = StockColor::colorI( pStockColorName );
const ColorI& color = StockColor::colorI(stockColorName);
// Format stock color.
char* returnBuffer = Con::getReturnBuffer(256);
dSprintf(returnBuffer, 256, "%d %d %d %d", color.red, color.green, color.blue, color.alpha);
return(returnBuffer);
return color;
}

View file

@ -50,7 +50,7 @@ static const char *packetTypeNames[] =
//-----------------------------------------------------------------
//-----------------------------------------------------------------
//-----------------------------------------------------------------
DefineConsoleFunction( DNetSetLogging, void, (bool enabled), , "(bool enabled)"
DefineEngineFunction( DNetSetLogging, void, (bool enabled), , "(bool enabled)"
"@brief Enables logging of the connection protocols\n\n"
"When enabled a lot of network debugging information is sent to the console.\n"
"@param enabled True to enable, false to disable\n"

View file

@ -484,7 +484,7 @@ static ConsoleDocFragment _FileObjectwriteObject2(
"FileObject",
"void writeObject( SimObject* object, string prepend);");
DefineConsoleMethod( FileObject, writeObject, void, (const char * simName, const char * objName), (""), "FileObject.writeObject(SimObject, object prepend)"
DefineEngineMethod( FileObject, writeObject, void, (const char * simName, const char * objName), (""), "FileObject.writeObject(SimObject, object prepend)"
"@hide")
{
SimObject* obj = Sim::findObject( simName );

View file

@ -21,7 +21,7 @@
//-----------------------------------------------------------------------------
#include "core/frameAllocator.h"
#include "console/console.h"
#include "console/engineAPI.h"
U8* FrameAllocator::smBuffer = NULL;
U32 FrameAllocator::smWaterMark = 0;
@ -30,7 +30,7 @@ U32 FrameAllocator::smHighWaterMark = 0;
#ifdef TORQUE_DEBUG
U32 FrameAllocator::smMaxFrameAllocation = 0;
ConsoleFunction(getMaxFrameAllocation, S32, 1,1, "getMaxFrameAllocation();")
DefineEngineFunction(getMaxFrameAllocation, S32, (),,"")
{
return FrameAllocator::getMaxFrameAllocation();
}

View file

@ -222,18 +222,17 @@ ResourceBase ResourceManager::nextResource()
ConsoleFunctionGroupBegin(ResourceManagerFunctions, "Resource management functions.");
ConsoleFunction(resourceDump, void, 1, 1, "()"
"@brief List the currently managed resources\n\n"
"Currently used by editors only, internal\n"
"@ingroup Editors\n"
"@internal")
DefineEngineFunction(resourceDump, void, (),,
"@brief List the currently managed resources\n\n"
"Currently used by editors only, internal\n"
"@ingroup Editors\n"
"@internal")
{
#ifdef TORQUE_DEBUG
ResourceManager::get().dumpToConsole();
#endif
}
DefineEngineFunction( reloadResource, void, ( const char* path ),,
"Force the resource at specified input path to be reloaded\n"
"@param path Path to the resource to be reloaded\n\n"

View file

@ -140,7 +140,7 @@ class HuffmanProcessor
static HuffmanProcessor g_huffProcessor;
bool readHuffBuffer(BitStream* pStream, char* out_pBuffer);
bool readHuffBuffer(BitStream* pStream, char* out_pBuffer, S32 maxLen);
bool writeHuffBuffer(BitStream* pStream, const char* out_pBuffer, S32 maxLen);
};
@ -488,24 +488,51 @@ void BitStream::readAffineTransform(MatrixF* matrix)
void BitStream::writeQuat( const QuatF& quat, U32 bitCount )
{
writeSignedFloat( quat.x, bitCount );
writeSignedFloat( quat.y, bitCount );
writeSignedFloat( quat.z, bitCount );
writeFlag( quat.w < 0.0f );
F32 quatVals[4] = { quat.x, quat.y, quat.z, quat.w };
bool flipQuat = (quatVals[0] < 0);
F32 maxVal = mFabs(quatVals[0]);
S32 idxMax = 0;
for (S32 i = 1; i < 4; ++i)
{
if (mFabs(quatVals[i]) > maxVal)
{
idxMax = i;
maxVal = mFabs(quatVals[i]);
flipQuat = (quatVals[i] < 0);
}
}
writeInt(idxMax, 2);
for (S32 i = 0; i < 4; ++i)
{
if (i == idxMax)
continue;
F32 curValue = (flipQuat ? -quatVals[i] : quatVals[i]) * (F32) M_SQRT2;
writeSignedFloat( curValue, bitCount );
}
}
void BitStream::readQuat( QuatF *outQuat, U32 bitCount )
{
outQuat->x = readSignedFloat( bitCount );
outQuat->y = readSignedFloat( bitCount );
outQuat->z = readSignedFloat( bitCount );
F32 quatVals[4];
F32 sum = 0.0f;
outQuat->w = mSqrt( 1.0 - getMin( mSquared( outQuat->x ) +
mSquared( outQuat->y ) +
mSquared( outQuat->z ),
1.0f ) );
if ( readFlag() )
outQuat->w = -outQuat->w;
S32 idxMax = readInt( 2 );
for (S32 i = 0; i < 4; ++i)
{
if (i == idxMax)
continue;
quatVals[i] = readSignedFloat( bitCount ) * M_SQRTHALF_F;
sum += quatVals[i] * quatVals[i];
}
if (sum > 1.0f)
quatVals[idxMax] = 1.0f;
else
quatVals[idxMax] = mSqrt(1.0f - sum);
outQuat->set(quatVals[0], quatVals[1], quatVals[2], quatVals[3]);
}
void BitStream::writeBits( const BitVector &bitvec )
@ -667,12 +694,12 @@ void BitStream::readString(char buf[256])
if(readFlag())
{
S32 offset = readInt(8);
HuffmanProcessor::g_huffProcessor.readHuffBuffer(this, stringBuffer + offset);
HuffmanProcessor::g_huffProcessor.readHuffBuffer(this, stringBuffer + offset, 256 - offset);
dStrcpy(buf, stringBuffer, 256);
return;
}
}
HuffmanProcessor::g_huffProcessor.readHuffBuffer(this, buf);
HuffmanProcessor::g_huffProcessor.readHuffBuffer(this, buf, 256);
if(stringBuffer)
dStrcpy(stringBuffer, buf, 256);
}
@ -812,13 +839,16 @@ S16 HuffmanProcessor::determineIndex(HuffWrap& rWrap)
}
}
bool HuffmanProcessor::readHuffBuffer(BitStream* pStream, char* out_pBuffer)
bool HuffmanProcessor::readHuffBuffer(BitStream* pStream, char* out_pBuffer, S32 maxLen=256)
{
if (m_tablesBuilt == false)
buildTables();
if (pStream->readFlag()) {
S32 len = pStream->readInt(8);
if (len >= maxLen) {
len = maxLen;
}
for (S32 i = 0; i < len; i++) {
S32 index = 0;
while (true) {
@ -839,6 +869,9 @@ bool HuffmanProcessor::readHuffBuffer(BitStream* pStream, char* out_pBuffer)
} else {
// Uncompressed string...
U32 len = pStream->readInt(8);
if (len >= maxLen) {
len = maxLen;
}
pStream->read(len, out_pBuffer);
out_pBuffer[len] = '\0';
return true;

View file

@ -207,18 +207,18 @@ public:
void readAffineTransform(MatrixF*);
/// Writes a quaternion in a lossy compressed format that
/// is ( bitCount * 3 ) + 1 bits in size.
/// is ( bitCount * 3 ) + 2 bits in size.
///
/// @param quat The normalized quaternion to write.
/// @param bitCount The the storage space for the xyz component of
/// @param bitCount The the storage space for the packed components of
/// the quaternion.
///
void writeQuat( const QuatF& quat, U32 bitCount = 9 );
/// Reads a quaternion written with writeQuat.
///
/// @param quat The normalized quaternion to write.
/// @param bitCount The the storage space for the xyz component of
/// @param quat The quaternion that was read.
/// @param bitCount The the storage space for the packed components of
/// the quaternion. Must match the bitCount at write.
/// @see writeQuat
///

View file

@ -48,12 +48,12 @@
void dumpAllStrings();
};
DefineConsoleFunction( sbmDumpStats, void, (), , "()")
DefineEngineFunction( sbmDumpStats, void, (), , "()")
{
StringBufferManager::getManager().dumpStats();
}
DefineConsoleFunction( sbmDumpStrings, void, (), , "()")
DefineEngineFunction( sbmDumpStrings, void, (), , "()")
{
StringBufferManager::getManager().dumpAllStrings();
}

View file

@ -480,7 +480,7 @@ static U32 sgStringInstances;
#endif
DefineConsoleFunction( dumpStringMemStats, void, (), , "()"
DefineEngineFunction( dumpStringMemStats, void, (), , "()"
"@brief Dumps information about String memory usage\n\n"
"@ingroup Debugging\n"
"@ingroup Strings\n")