This commit is contained in:
2024-08-07 09:16:27 -04:00
parent fdfadd5c7e
commit 5f971cf684
5200 changed files with 731717 additions and 0 deletions

49
engine/SPACIAL.CPP Normal file
View File

@@ -0,0 +1,49 @@
#include <engine/spacial.hpp>
#include <common/array.hpp>
SpacialTransform::~SpacialTransform()
{
}
BOOL SpacialTransform::transform(Array<int> &srcVector,Array<int> &dstVector,WORD sizeFactor)
{
int inverseFactor((100.00/(float)sizeFactor)*100.00);
int outSegment(inverseFactor);
int inSegment(100);
int nextDestIndex(0);
int accumulator(0);
mNextInputIndex=-1;
dstVector.size((srcVector.size()*sizeFactor)/100.00);
if(!nextInput(srcVector))return FALSE;
while(TRUE)
{
if(outSegment<=inSegment)
{
accumulator+=((inSegment*mCurrentValue)+((100-inSegment)*mNextValue))*outSegment;
inSegment-=outSegment;
outSegment=inverseFactor;
accumulator*=(float)sizeFactor*.000001;
if(nextDestIndex>=dstVector.size())break;
dstVector[nextDestIndex++]=accumulator;
accumulator=0;
}
else
{
accumulator+=((inSegment*mCurrentValue)+((100-inSegment)*mNextValue))*inSegment;
outSegment-=inSegment;
inSegment=100;
if(!nextInput(srcVector))break;
}
}
return false;
}
BOOL SpacialTransform::nextInput(Array<int> &srcVector)
{
if(++mNextInputIndex>=srcVector.size())return FALSE;
mCurrentValue=srcVector[mNextInputIndex];
if(mNextInputIndex+1>=srcVector.size())mNextValue=mCurrentValue;
else mNextValue=srcVector[mNextInputIndex+1];
return TRUE;
}