mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 19:53:48 +00:00
Merge branch 'development' into EngineAPI-Refactor
This commit is contained in:
commit
3a71c75596
1937 changed files with 102332 additions and 70549 deletions
|
|
@ -78,7 +78,7 @@ ResizeBitStream::ResizeBitStream(U32 minSpace, U32 initialSize) : BitStream(NULL
|
|||
|
||||
ResizeBitStream::~ResizeBitStream()
|
||||
{
|
||||
dFree(dataPtr);
|
||||
dFree(mDataPtr);
|
||||
}
|
||||
|
||||
void ResizeBitStream::validate()
|
||||
|
|
@ -86,7 +86,7 @@ void ResizeBitStream::validate()
|
|||
if(getPosition() + mMinSpace > bufSize)
|
||||
{
|
||||
bufSize = getPosition() + mMinSpace * 2;
|
||||
dataPtr = (U8 *) dRealloc(dataPtr, bufSize);
|
||||
mDataPtr = (U8 *) dRealloc(mDataPtr, bufSize);
|
||||
|
||||
maxReadBitNum = bufSize << 3;
|
||||
maxWriteBitNum = bufSize << 3;
|
||||
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ HuffmanProcessor HuffmanProcessor::g_huffProcessor;
|
|||
|
||||
void BitStream::setBuffer(void *bufPtr, S32 size, S32 maxSize)
|
||||
{
|
||||
dataPtr = (U8 *) bufPtr;
|
||||
mDataPtr = (U8 *) bufPtr;
|
||||
bitNum = 0;
|
||||
bufSize = size;
|
||||
maxReadBitNum = size << 3;
|
||||
|
|
@ -178,7 +178,7 @@ U32 BitStream::getStreamSize()
|
|||
|
||||
U8 *BitStream::getBytePtr()
|
||||
{
|
||||
return dataPtr + getPosition();
|
||||
return mDataPtr + getPosition();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ U32 BitStream::getWriteByteSize()
|
|||
|
||||
void BitStream::clear()
|
||||
{
|
||||
dMemset(dataPtr, 0, bufSize);
|
||||
dMemset(mDataPtr, 0, bufSize);
|
||||
}
|
||||
|
||||
void BitStream::writeClassId(U32 classId, U32 classType, U32 classGroup)
|
||||
|
|
@ -242,9 +242,9 @@ void BitStream::writeBits(S32 bitCount, const void *bitPtr)
|
|||
for(S32 srcBitNum = 0;srcBitNum < bitCount;srcBitNum++)
|
||||
{
|
||||
if((*(ptr + (srcBitNum >> 3)) & (1 << (srcBitNum & 0x7))) != 0)
|
||||
*(dataPtr + (bitNum >> 3)) |= (1 << (bitNum & 0x7));
|
||||
*(mDataPtr + (bitNum >> 3)) |= (1 << (bitNum & 0x7));
|
||||
else
|
||||
*(dataPtr + (bitNum >> 3)) &= ~(1 << (bitNum & 0x7));
|
||||
*(mDataPtr + (bitNum >> 3)) &= ~(1 << (bitNum & 0x7));
|
||||
bitNum++;
|
||||
}
|
||||
}
|
||||
|
|
@ -252,14 +252,14 @@ void BitStream::writeBits(S32 bitCount, const void *bitPtr)
|
|||
void BitStream::setBit(S32 bitCount, bool set)
|
||||
{
|
||||
if(set)
|
||||
*(dataPtr + (bitCount >> 3)) |= (1 << (bitCount & 0x7));
|
||||
*(mDataPtr + (bitCount >> 3)) |= (1 << (bitCount & 0x7));
|
||||
else
|
||||
*(dataPtr + (bitCount >> 3)) &= ~(1 << (bitCount & 0x7));
|
||||
*(mDataPtr + (bitCount >> 3)) &= ~(1 << (bitCount & 0x7));
|
||||
}
|
||||
|
||||
bool BitStream::testBit(S32 bitCount)
|
||||
{
|
||||
return (*(dataPtr + (bitCount >> 3)) & (1 << (bitCount & 0x7))) != 0;
|
||||
return (*(mDataPtr + (bitCount >> 3)) & (1 << (bitCount & 0x7))) != 0;
|
||||
}
|
||||
|
||||
bool BitStream::writeFlag(bool val)
|
||||
|
|
@ -271,9 +271,9 @@ bool BitStream::writeFlag(bool val)
|
|||
return false;
|
||||
}
|
||||
if(val)
|
||||
*(dataPtr + (bitNum >> 3)) |= (1 << (bitNum & 0x7));
|
||||
*(mDataPtr + (bitNum >> 3)) |= (1 << (bitNum & 0x7));
|
||||
else
|
||||
*(dataPtr + (bitNum >> 3)) &= ~(1 << (bitNum & 0x7));
|
||||
*(mDataPtr + (bitNum >> 3)) &= ~(1 << (bitNum & 0x7));
|
||||
bitNum++;
|
||||
return (val);
|
||||
}
|
||||
|
|
@ -289,7 +289,7 @@ void BitStream::readBits(S32 bitCount, void *bitPtr)
|
|||
AssertWarn(false, "Out of range read");
|
||||
return;
|
||||
}
|
||||
U8 *stPtr = dataPtr + (bitNum >> 3);
|
||||
U8 *stPtr = mDataPtr + (bitNum >> 3);
|
||||
S32 byteCount = (bitCount + 7) >> 3;
|
||||
|
||||
U8 *ptr = (U8 *) bitPtr;
|
||||
|
|
@ -298,7 +298,7 @@ void BitStream::readBits(S32 bitCount, void *bitPtr)
|
|||
S32 upShift = 8 - downShift;
|
||||
|
||||
U8 curB = *stPtr;
|
||||
const U8 *stEnd = dataPtr + bufSize;
|
||||
const U8 *stEnd = mDataPtr + bufSize;
|
||||
while(byteCount--)
|
||||
{
|
||||
stPtr++;
|
||||
|
|
@ -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 )
|
||||
|
|
@ -628,7 +655,7 @@ void InfiniteBitStream::validate(U32 upcomingBytes)
|
|||
if(getPosition() + upcomingBytes + mMinSpace > bufSize)
|
||||
{
|
||||
bufSize = getPosition() + upcomingBytes + mMinSpace;
|
||||
dataPtr = (U8 *) dRealloc(dataPtr, bufSize);
|
||||
mDataPtr = (U8 *) dRealloc(mDataPtr, bufSize);
|
||||
|
||||
maxReadBitNum = bufSize << 3;
|
||||
maxWriteBitNum = bufSize << 3;
|
||||
|
|
@ -643,11 +670,11 @@ void InfiniteBitStream::compact()
|
|||
|
||||
// Copy things...
|
||||
bufSize = getPosition() + mMinSpace * 2;
|
||||
dMemcpy(tmp, dataPtr, oldSize);
|
||||
dMemcpy(tmp, mDataPtr, oldSize);
|
||||
|
||||
// And clean up.
|
||||
dFree(dataPtr);
|
||||
dataPtr = tmp;
|
||||
dFree(mDataPtr);
|
||||
mDataPtr = tmp;
|
||||
|
||||
maxReadBitNum = bufSize << 3;
|
||||
maxWriteBitNum = bufSize << 3;
|
||||
|
|
@ -655,7 +682,7 @@ void InfiniteBitStream::compact()
|
|||
|
||||
void InfiniteBitStream::writeToStream(Stream &s)
|
||||
{
|
||||
s.write(getPosition(), dataPtr);
|
||||
s.write(getPosition(), mDataPtr);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -781,7 +808,7 @@ void HuffmanProcessor::generateCodes(BitStream& rBS, S32 index, S32 depth)
|
|||
// leaf node, copy the code in, and back out...
|
||||
HuffLeaf& rLeaf = m_huffLeaves[-(index + 1)];
|
||||
|
||||
dMemcpy(&rLeaf.code, rBS.dataPtr, sizeof(rLeaf.code));
|
||||
dMemcpy(&rLeaf.code, rBS.mDataPtr, sizeof(rLeaf.code));
|
||||
rLeaf.numBits = depth;
|
||||
} else {
|
||||
HuffNode& rNode = m_huffNodes[index];
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class QuatF;
|
|||
class BitStream : public Stream
|
||||
{
|
||||
protected:
|
||||
U8 *dataPtr;
|
||||
U8 *mDataPtr;
|
||||
S32 bitNum;
|
||||
S32 bufSize;
|
||||
bool error;
|
||||
|
|
@ -68,7 +68,7 @@ public:
|
|||
static void sendPacketStream(const NetAddress *addr);
|
||||
|
||||
void setBuffer(void *bufPtr, S32 bufSize, S32 maxSize = 0);
|
||||
U8* getBuffer() { return dataPtr; }
|
||||
U8* getBuffer() { return mDataPtr; }
|
||||
U8* getBytePtr();
|
||||
|
||||
U32 getReadByteSize();
|
||||
|
|
@ -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
|
||||
///
|
||||
|
|
@ -337,7 +337,7 @@ inline bool BitStream::readFlag()
|
|||
return false;
|
||||
}
|
||||
S32 mask = 1 << (bitNum & 0x7);
|
||||
bool ret = (*(dataPtr + (bitNum >> 3)) & mask) != 0;
|
||||
bool ret = (*(mDataPtr + (bitNum >> 3)) & mask) != 0;
|
||||
bitNum++;
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ void _StringTable::resize(const U32 _newSize)
|
|||
walk = head;
|
||||
while(walk) {
|
||||
U32 key;
|
||||
Node *temp = walk;
|
||||
temp = walk;
|
||||
|
||||
walk = walk->next;
|
||||
key = hashString(temp->val);
|
||||
|
|
|
|||
|
|
@ -113,14 +113,14 @@ inline void SparseArray<T>::insert(T* pObject, U32 key)
|
|||
template <class T>
|
||||
inline T* SparseArray<T>::remove(U32 key)
|
||||
{
|
||||
U32 remove = key % mModulus;
|
||||
Node* probe = &mSentryTables[remove];
|
||||
U32 sentryID = key % mModulus;
|
||||
Node* probe = &mSentryTables[sentryID];
|
||||
while (probe->next != NULL) {
|
||||
if (probe->next->key == key) {
|
||||
Node* remove = probe->next;
|
||||
T* pReturn = remove->pObject;
|
||||
probe->next = remove->next;
|
||||
delete remove;
|
||||
Node* nextProbe = probe->next;
|
||||
T* pReturn = nextProbe->pObject;
|
||||
probe->next = nextProbe->next;
|
||||
delete nextProbe;
|
||||
return pReturn;
|
||||
}
|
||||
probe = probe->next;
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ void SignalBase::DelegateLink::insert(DelegateLink* node, F32 order)
|
|||
{
|
||||
// Note: can only legitimately be called on list head
|
||||
DelegateLink * walk = next;
|
||||
while (order >= walk->order && walk->next != this)
|
||||
while (order >= walk->mOrder && walk->next != this)
|
||||
walk = walk->next;
|
||||
if (order >= walk->order)
|
||||
if (order >= walk->mOrder)
|
||||
{
|
||||
// insert after walk
|
||||
node->prev = walk;
|
||||
|
|
@ -46,7 +46,7 @@ void SignalBase::DelegateLink::insert(DelegateLink* node, F32 order)
|
|||
walk->prev->next = node;
|
||||
walk->prev = node;
|
||||
}
|
||||
node->order = order;
|
||||
node->mOrder = order;
|
||||
}
|
||||
|
||||
void SignalBase::DelegateLink::unlink()
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public:
|
|||
SignalBase()
|
||||
{
|
||||
mList.next = mList.prev = &mList;
|
||||
mList.order = 0.5f;
|
||||
mList.mOrder = 0.5f;
|
||||
}
|
||||
|
||||
~SignalBase();
|
||||
|
|
@ -72,7 +72,7 @@ protected:
|
|||
struct DelegateLink
|
||||
{
|
||||
DelegateLink *next,*prev;
|
||||
F32 order;
|
||||
F32 mOrder;
|
||||
|
||||
void insert(DelegateLink* node, F32 order);
|
||||
void unlink();
|
||||
|
|
@ -191,7 +191,7 @@ public:
|
|||
for ( DelegateLink *ptr = base.mList.next; ptr != &base.mList; ptr = ptr->next )
|
||||
{
|
||||
DelegateLinkImpl *del = static_cast<DelegateLinkImpl*>( ptr );
|
||||
notify( del->mDelegate, del->order );
|
||||
notify( del->mDelegate, del->mOrder );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -808,7 +808,6 @@ bool MountSystem::isDirectory(const Path& path, FileSystemRef fsRef)
|
|||
if (fnRef.isNull())
|
||||
return false;
|
||||
|
||||
FileNode::Attributes attr;
|
||||
if (fnRef->getAttributes(&attr))
|
||||
return attr.flags & FileNode::Directory;
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue