- fixed some warnings and updated vectors.h

This commit is contained in:
Christoph Oelckers 2022-10-15 12:10:01 +02:00
parent 1241b277f3
commit 57add9a45c
3 changed files with 29 additions and 11 deletions

View file

@ -126,7 +126,7 @@ bool InterplayDecoder::FillSamples(void *buff, int len)
audio.Packets.pop_front(); audio.Packets.pop_front();
plock.unlock(); plock.unlock();
int nSamples = pkt.nSize; int nSamples = (int)pkt.nSize;
const uint8_t *samplePtr = pkt.pData.get(); const uint8_t *samplePtr = pkt.pData.get();
if (audio.bCompressed) if (audio.bCompressed)
{ {
@ -153,7 +153,7 @@ bool InterplayDecoder::FillSamples(void *buff, int len)
audio.samples[audio.nWrite++] = predictor[ch]; audio.samples[audio.nWrite++] = predictor[ch];
// toggle channel // toggle channel
ch ^= stereo; ch ^= stereo ? 1 : 0;
} }
} }
else if (audio.nBitDepth == 8) else if (audio.nBitDepth == 8)

View file

@ -732,7 +732,7 @@ void SmackerDecoder::GetNextFrame()
framePacketData.pop_front(); framePacketData.pop_front();
flock.unlock(); flock.unlock();
uint32_t frameSize = pkt.size; uint32_t frameSize = (uint32_t)pkt.size;
uint8_t frameFlag = frameFlags[currentFrame]; uint8_t frameFlag = frameFlags[currentFrame];
const uint8_t *packetDataPtr = pkt.data.get(); const uint8_t *packetDataPtr = pkt.data.get();
@ -1235,7 +1235,7 @@ uint32_t SmackerDecoder::GetAudioData(uint32_t trackIndex, int16_t *audioBuffer)
track->bytesReadThisFrame = 0; track->bytesReadThisFrame = 0;
const uint8_t *packetDataPtr = pkt.data.get(); const uint8_t *packetDataPtr = pkt.data.get();
uint32_t size = pkt.size; uint32_t size = (uint32_t)pkt.size;
DecodeAudio(packetDataPtr, size, *track); DecodeAudio(packetDataPtr, size, *track);

View file

@ -577,7 +577,7 @@ struct TVector3
} }
up = n ^right; up = n ^right;
right.MakeUnit();; right.MakeUnit();
up.MakeUnit(); up.MakeUnit();
} }
@ -665,6 +665,7 @@ struct TVector3
template<class vec_t> template<class vec_t>
struct TVector4 struct TVector4
{ {
typedef TVector2<vec_t> Vector2;
typedef TVector3<vec_t> Vector3; typedef TVector3<vec_t> Vector3;
vec_t X, Y, Z, W; vec_t X, Y, Z, W;
@ -723,6 +724,29 @@ struct TVector4
return X != other.X || Y != other.Y || Z != other.Z || W != other.W; return X != other.X || Y != other.Y || Z != other.Z || W != other.W;
} }
// returns the XY fields as a 2D-vector.
const Vector2& XY() const
{
return *reinterpret_cast<const Vector2*>(this);
}
Vector2& XY()
{
return *reinterpret_cast<Vector2*>(this);
}
// returns the XY fields as a 2D-vector.
const Vector3& XYZ() const
{
return *reinterpret_cast<const Vector3*>(this);
}
Vector3& XYZ()
{
return *reinterpret_cast<Vector3*>(this);
}
// Test for approximate equality // Test for approximate equality
bool ApproximatelyEquals(const TVector4 &other) const bool ApproximatelyEquals(const TVector4 &other) const
{ {
@ -838,12 +862,6 @@ struct TVector4
return *this; return *this;
} }
// returns the XYZ fields as a 3D-vector.
Vector3 XYZ() const
{
return{ X, Y, Z };
}
// Add a 4D vector and a 3D vector. // Add a 4D vector and a 3D vector.
friend TVector4 operator+ (const TVector4 &v4, const Vector3 &v3) friend TVector4 operator+ (const TVector4 &v4, const Vector3 &v3)
{ {