Browse Source

Convert hsMatrix44 hsTArrays to std::vectors

Adam Johnson 12 years ago
parent
commit
8c37858de8
  1. 28
      Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpans.cpp
  2. 11
      Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpans.h
  3. 2
      Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpansExport.cpp

28
Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpans.cpp

@ -1045,10 +1045,10 @@ void plDrawableSpans::Read( hsStream* s, hsResMgr* mgr )
/// Read in the matrix palette (if any) /// Read in the matrix palette (if any)
count = s->ReadLE32(); count = s->ReadLE32();
fLocalToWorlds.SetCount(count); fLocalToWorlds.resize(count);
fWorldToLocals.SetCount(count); fWorldToLocals.resize(count);
fLocalToBones.SetCount(count); fLocalToBones.resize(count);
fBoneToLocals.SetCount(count); fBoneToLocals.resize(count);
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
{ {
fLocalToWorlds[i].Read(s); fLocalToWorlds[i].Read(s);
@ -2209,16 +2209,12 @@ uint32_t plDrawableSpans::AppendDIMatrixSpans(int n)
if( fNeedCleanup ) if( fNeedCleanup )
IRemoveGarbage(); IRemoveGarbage();
uint32_t baseIdx = fLocalToWorlds.GetCount(); uint32_t baseIdx = fLocalToWorlds.size();
fLocalToWorlds.Expand(baseIdx + n); fLocalToWorlds.resize(baseIdx + n);
fLocalToWorlds.SetCount(baseIdx + n); fWorldToLocals.resize(baseIdx + n);
fWorldToLocals.Expand(baseIdx + n);
fWorldToLocals.SetCount(baseIdx + n);
fLocalToBones.Expand(baseIdx + n); fLocalToBones.resize(baseIdx + n);
fLocalToBones.SetCount(baseIdx + n); fBoneToLocals.resize(baseIdx + n);
fBoneToLocals.Expand(baseIdx + n);
fBoneToLocals.SetCount(baseIdx + n);
int i; int i;
for( i = baseIdx; i < baseIdx + n; i++ ) for( i = baseIdx; i < baseIdx + n; i++ )
@ -2267,7 +2263,7 @@ uint32_t plDrawableSpans::FindBoneBaseMatrix(const hsTArray<hsMatrix44>& initL2B
// runtime, a sharable bone pallete won't be found by scanning fSpans. // runtime, a sharable bone pallete won't be found by scanning fSpans.
// We have to do a larger search through all bone matrices. // We have to do a larger search through all bone matrices.
int i; int i;
for( i = 0; i + initL2B.GetCount() < fLocalToBones.GetCount(); i++ ) for( i = 0; i + initL2B.GetCount() < fLocalToBones.size(); i++ )
{ {
int j; int j;
for( j = 0; j < initL2B.GetCount(); j++ ) for( j = 0; j < initL2B.GetCount(); j++ )
@ -2894,7 +2890,7 @@ void plDrawableSpans::ICleanupMatrices()
} }
} }
for( j = 0; j < fLocalToWorlds.GetCount(); j++ ) for( j = 0; j < fLocalToWorlds.size(); j++ )
{ {
if( !usedMatrices.IsBitSet(j) ) if( !usedMatrices.IsBitSet(j) )
{ {
@ -2910,7 +2906,7 @@ void plDrawableSpans::ICleanupMatrices()
} }
} }
} }
for( i = j+1; i < fLocalToWorlds.GetCount(); i++ ) for( i = j+1; i < fLocalToWorlds.size(); i++ )
{ {
fLocalToWorlds[i] = fLocalToWorlds[i-1]; fLocalToWorlds[i] = fLocalToWorlds[i-1];
fWorldToLocals[i] = fWorldToLocals[i-1]; fWorldToLocals[i] = fWorldToLocals[i-1];

11
Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpans.h

@ -70,6 +70,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsBounds.h" #include "hsBounds.h"
#include "hsMatrix44.h" #include "hsMatrix44.h"
#include "plSpanTypes.h" #include "plSpanTypes.h"
#include <vector>
class plPipeline; class plPipeline;
class plMessage; class plMessage;
@ -131,11 +132,11 @@ class plDrawableSpans : public plDrawable
hsMatrix44 fLocalToWorld; hsMatrix44 fLocalToWorld;
hsMatrix44 fWorldToLocal; hsMatrix44 fWorldToLocal;
hsTArray<hsMatrix44> fLocalToWorlds; std::vector<hsMatrix44> fLocalToWorlds;
hsTArray<hsMatrix44> fWorldToLocals; std::vector<hsMatrix44> fWorldToLocals;
hsTArray<hsMatrix44> fLocalToBones; std::vector<hsMatrix44> fLocalToBones;
hsTArray<hsMatrix44> fBoneToLocals; std::vector<hsMatrix44> fBoneToLocals;
hsTArray<hsGMaterial *> fMaterials; hsTArray<hsGMaterial *> fMaterials;
@ -283,7 +284,7 @@ class plDrawableSpans : public plDrawable
virtual uint32_t GetNumSpans( void ) const { return fSpans.GetCount(); } virtual uint32_t GetNumSpans( void ) const { return fSpans.GetCount(); }
virtual const hsTArray<plSpan *> &GetSpanArray( void ) const { return fSpans; } virtual const hsTArray<plSpan *> &GetSpanArray( void ) const { return fSpans; }
hsMatrix44* GetMatrixPalette(int baseMatrix) const { return &fLocalToWorlds[baseMatrix]; } hsMatrix44* GetMatrixPalette(int baseMatrix) const { return const_cast<hsMatrix44*>(&fLocalToWorlds[baseMatrix]); }
const hsMatrix44& GetPaletteMatrix(int i) const { return fLocalToWorlds[i]; } const hsMatrix44& GetPaletteMatrix(int i) const { return fLocalToWorlds[i]; }
void SetInitialBone(int i, const hsMatrix44& l2b, const hsMatrix44& b2l); void SetInitialBone(int i, const hsMatrix44& l2b, const hsMatrix44& b2l);

2
Sources/Plasma/PubUtilLib/plDrawable/plDrawableSpansExport.cpp

@ -163,7 +163,7 @@ void plDrawableSpans::Write( hsStream* s, hsResMgr* mgr )
fSourceSpans[ i ]->Write( s ); fSourceSpans[ i ]->Write( s );
} }
count = fLocalToWorlds.GetCount(); count = fLocalToWorlds.size();
s->WriteLE32(count); s->WriteLE32(count);
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
{ {

Loading…
Cancel
Save