Moved LLAlignedArray from llmath to llcommon and put template func impls in header to work around Mac 4.3.3 link issue.
parent
b628518fd7
commit
c04f4f66c8
|
|
@ -121,6 +121,7 @@ set(llcommon_HEADER_FILES
|
|||
linden_common.h
|
||||
linked_lists.h
|
||||
llaccountingcost.h
|
||||
llalignedarray.h
|
||||
llallocator.h
|
||||
llallocator_heap_profile.h
|
||||
llagentconstants.h
|
||||
|
|
|
|||
|
|
@ -96,93 +96,6 @@ extern BOOL gDebugGL;
|
|||
|
||||
bool less_than_max_mag(const LLVector4a& vec);
|
||||
|
||||
template <class T, U32 alignment>
|
||||
LLAlignedArray<T, alignment>::LLAlignedArray()
|
||||
{
|
||||
mArray = NULL;
|
||||
mElementCount = 0;
|
||||
mCapacity = 0;
|
||||
}
|
||||
|
||||
template <class T, U32 alignment>
|
||||
LLAlignedArray<T, alignment>::~LLAlignedArray()
|
||||
{
|
||||
ll_aligned_free(mArray);
|
||||
mArray = NULL;
|
||||
mElementCount = 0;
|
||||
mCapacity = 0;
|
||||
}
|
||||
|
||||
template <class T, U32 alignment>
|
||||
void LLAlignedArray<T, alignment>::push_back(const T& elem)
|
||||
{
|
||||
T* old_buf = NULL;
|
||||
if (mCapacity <= mElementCount)
|
||||
{
|
||||
mCapacity++;
|
||||
mCapacity *= 2;
|
||||
T* new_buf = (T*) ll_aligned_malloc(mCapacity*sizeof(T), alignment);
|
||||
if (mArray)
|
||||
{
|
||||
LLVector4a::memcpyNonAliased16((F32*) new_buf, (F32*) mArray, sizeof(T)*mElementCount);
|
||||
}
|
||||
old_buf = mArray;
|
||||
mArray = new_buf;
|
||||
}
|
||||
|
||||
mArray[mElementCount++] = elem;
|
||||
|
||||
//delete old array here to prevent error on a.push_back(a[0])
|
||||
ll_aligned_free(old_buf);
|
||||
}
|
||||
|
||||
template <class T, U32 alignment>
|
||||
void LLAlignedArray<T, alignment>::resize(U32 size)
|
||||
{
|
||||
if (mCapacity < size)
|
||||
{
|
||||
mCapacity = size+mCapacity*2;
|
||||
T* new_buf = mCapacity > 0 ? (T*) ll_aligned_malloc(mCapacity*sizeof(T), alignment) : NULL;
|
||||
if (mArray)
|
||||
{
|
||||
LLVector4a::memcpyNonAliased16((F32*) new_buf, (F32*) mArray, sizeof(T)*mElementCount);
|
||||
ll_aligned_free(mArray);
|
||||
}
|
||||
|
||||
/*for (U32 i = mElementCount; i < mCapacity; ++i)
|
||||
{
|
||||
new(new_buf+i) T();
|
||||
}*/
|
||||
mArray = new_buf;
|
||||
}
|
||||
|
||||
mElementCount = size;
|
||||
}
|
||||
|
||||
|
||||
template <class T, U32 alignment>
|
||||
T& LLAlignedArray<T, alignment>::operator[](int idx)
|
||||
{
|
||||
llassert(idx < mElementCount);
|
||||
return mArray[idx];
|
||||
}
|
||||
|
||||
template <class T, U32 alignment>
|
||||
const T& LLAlignedArray<T, alignment>::operator[](int idx) const
|
||||
{
|
||||
llassert(idx < mElementCount);
|
||||
return mArray[idx];
|
||||
}
|
||||
|
||||
template <class T, U32 alignment>
|
||||
T* LLAlignedArray<T, alignment>::append(S32 N)
|
||||
{
|
||||
U32 sz = size();
|
||||
resize(sz+N);
|
||||
return &((*this)[sz]);
|
||||
}
|
||||
|
||||
|
||||
BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm)
|
||||
{
|
||||
LLVector3 test = (pt2-pt1)%(pt3-pt2);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ class LLVolumeFace;
|
|||
class LLVolume;
|
||||
class LLVolumeTriangle;
|
||||
|
||||
#include "llalignedarray.h"
|
||||
#include "lldarray.h"
|
||||
#include "lluuid.h"
|
||||
#include "v4color.h"
|
||||
|
|
@ -195,26 +196,6 @@ const U8 LL_SCULPT_FLAG_MIRROR = 128;
|
|||
|
||||
const S32 LL_SCULPT_MESH_MAX_FACES = 8;
|
||||
|
||||
template <class T, U32 alignment>
|
||||
class LLAlignedArray
|
||||
{
|
||||
public:
|
||||
T* mArray;
|
||||
U32 mElementCount;
|
||||
U32 mCapacity;
|
||||
|
||||
LLAlignedArray();
|
||||
~LLAlignedArray();
|
||||
|
||||
void push_back(const T& elem);
|
||||
U32 size() const { return mElementCount; }
|
||||
void resize(U32 size);
|
||||
T* append(S32 N);
|
||||
T& operator[](int idx);
|
||||
const T& operator[](int idx) const;
|
||||
};
|
||||
|
||||
|
||||
class LLProfileParams
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
Loading…
Reference in New Issue