Engine directory for ticket #1

This commit is contained in:
DavidWyand-GG 2012-09-19 11:15:01 -04:00
parent 352279af7a
commit 7dbfe6994d
3795 changed files with 1363358 additions and 0 deletions

View file

@ -0,0 +1,43 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "sfx/null/sfxNullBuffer.h"
#include "sfx/sfxInternal.h"
SFXNullBuffer::SFXNullBuffer( const ThreadSafeRef< SFXStream >& stream, SFXDescription* description )
: Parent( stream, description, false )
{
mStatus = STATUS_Ready;
}
SFXNullBuffer::~SFXNullBuffer()
{
}
void SFXNullBuffer::write( SFXInternal::SFXStreamPacket* const* packets, U32 num )
{
// Should never really be called, but to be safe...
for( U32 i = 0; i < num; ++ i )
destructSingle( packets[ i ] );
}

View file

@ -0,0 +1,49 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _SFXNULLBUFFER_H_
#define _SFXNULLBUFFER_H_
#ifndef _SFXBUFFER_H_
#include "sfx/sfxBuffer.h"
#endif
class SFXNullBuffer : public SFXBuffer
{
friend class SFXNullDevice;
typedef SFXBuffer Parent;
protected:
SFXNullBuffer( const ThreadSafeRef< SFXStream >& stream, SFXDescription* description );
// SFXBuffer.
virtual void write( SFXInternal::SFXStreamPacket* const* packets, U32 num );
virtual void _flush() {}
public:
virtual ~SFXNullBuffer();
};
#endif // _SFXNULLBUFFER_H_

View file

@ -0,0 +1,74 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "sfx/null/sfxNullDevice.h"
#include "sfx/null/sfxNullBuffer.h"
#include "sfx/sfxInternal.h"
SFXNullDevice::SFXNullDevice( SFXProvider* provider,
String name,
bool useHardware,
S32 maxBuffers )
: SFXDevice( name, provider, useHardware, maxBuffers )
{
mMaxBuffers = getMax( maxBuffers, 8 );
}
SFXNullDevice::~SFXNullDevice()
{
}
SFXBuffer* SFXNullDevice::createBuffer( const ThreadSafeRef< SFXStream >& stream, SFXDescription* description )
{
SFXNullBuffer* buffer = new SFXNullBuffer( stream, description );
_addBuffer( buffer );
return buffer;
}
SFXVoice* SFXNullDevice::createVoice( bool is3D, SFXBuffer *buffer )
{
// Don't bother going any further if we've
// exceeded the maximum voices.
if ( mVoices.size() >= mMaxBuffers )
return NULL;
AssertFatal( buffer, "SFXNullDevice::createVoice() - Got null buffer!" );
SFXNullBuffer* nullBuffer = dynamic_cast<SFXNullBuffer*>( buffer );
AssertFatal( nullBuffer, "SFXNullDevice::createVoice() - Got bad buffer!" );
SFXNullVoice* voice = new SFXNullVoice( nullBuffer );
if ( !voice )
return NULL;
_addVoice( voice );
return voice;
}
void SFXNullDevice::update()
{
// Do nothing. Prevent SFXDevice from running
// its thing.
}

View file

@ -0,0 +1,63 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _SFXNULLDEVICE_H_
#define _SFXNULLDEVICE_H_
class SFXProvider;
#ifndef _SFXDEVICE_H_
#include "sfx/sfxDevice.h"
#endif
#ifndef _SFXPROVIDER_H_
#include "sfx/sfxProvider.h"
#endif
#ifndef _SFXNULLBUFFER_H_
#include "sfx/null/sfxNullBuffer.h"
#endif
#ifndef _SFXNULLVOICE_H_
#include "sfx/null/sfxNullVoice.h"
#endif
class SFXNullDevice : public SFXDevice
{
typedef SFXDevice Parent;
public:
SFXNullDevice( SFXProvider* provider,
String name,
bool useHardware,
S32 maxBuffers );
virtual ~SFXNullDevice();
public:
// SFXDevice.
virtual SFXBuffer* createBuffer( const ThreadSafeRef< SFXStream >& stream, SFXDescription* description );
virtual SFXVoice* createVoice( bool is3D, SFXBuffer *buffer );
virtual void update();
};
#endif // _SFXNULLDEVICE_H_

View file

@ -0,0 +1,97 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "sfx/sfxProvider.h"
#include "sfx/null/sfxNullDevice.h"
#include "core/strings/stringFunctions.h"
#include "core/module.h"
class SFXNullProvider : public SFXProvider
{
public:
SFXNullProvider()
: SFXProvider( "Null" ) {}
virtual ~SFXNullProvider();
protected:
void addDeviceDesc( const String& name, const String& desc );
void init();
public:
SFXDevice* createDevice( const String& deviceName, bool useHardware, S32 maxBuffers );
};
MODULE_BEGIN( SFXNull )
MODULE_INIT_BEFORE( SFX )
MODULE_SHUTDOWN_AFTER( SFX )
SFXNullProvider* mProvider;
MODULE_INIT
{
mProvider = new SFXNullProvider;
}
MODULE_SHUTDOWN
{
delete mProvider;
}
MODULE_END;
void SFXNullProvider::init()
{
regProvider( this );
addDeviceDesc( "Null", "SFX Null Device" );
}
SFXNullProvider::~SFXNullProvider()
{
}
void SFXNullProvider::addDeviceDesc( const String& name, const String& desc )
{
SFXDeviceInfo* info = new SFXDeviceInfo;
info->name = desc;
info->driver = name;
info->hasHardware = false;
info->maxBuffers = 8;
mDeviceInfo.push_back( info );
}
SFXDevice* SFXNullProvider::createDevice( const String& deviceName, bool useHardware, S32 maxBuffers )
{
SFXDeviceInfo* info = _findDeviceInfo( deviceName );
// Do we find one to create?
if ( info )
return new SFXNullDevice( this, info->name, useHardware, maxBuffers );
return NULL;
}

View file

@ -0,0 +1,121 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "sfx/null/sfxNullVoice.h"
#include "sfx/null/sfxNullBuffer.h"
#include "sfx/sfxInternal.h"
SFXNullVoice::SFXNullVoice( SFXNullBuffer* buffer )
: Parent( buffer ),
mIsLooping( false )
{
}
SFXNullVoice::~SFXNullVoice()
{
}
SFXStatus SFXNullVoice::_status() const
{
if( !mIsLooping
&& mPlayTimer.isStarted()
&& !mPlayTimer.isPaused()
&& mPlayTimer.getPosition() >= mBuffer->getDuration() )
mPlayTimer.stop();
if( mPlayTimer.isPaused() )
return SFXStatusPaused;
else if( mPlayTimer.isStarted() )
return SFXStatusPlaying;
else
return SFXStatusStopped;
}
void SFXNullVoice::_play()
{
mPlayTimer.start();
}
void SFXNullVoice::_pause()
{
mPlayTimer.pause();
}
void SFXNullVoice::_stop()
{
mPlayTimer.stop();
}
void SFXNullVoice::_seek( U32 sample )
{
const U32 sampleTime = mBuffer->getFormat().getDuration( sample );
mPlayTimer.setPosition( sampleTime );
}
void SFXNullVoice::play( bool looping )
{
mIsLooping = looping;
mPlayTimer.start();
}
U32 SFXNullVoice::_tell() const
{
U32 ms = _getPlayTime();
const SFXFormat& format = mBuffer->getFormat();
return ( format.getDataLength( ms ) / format.getBytesPerSample() );
}
SFXStatus SFXNullVoice::getStatus() const
{
return _status();
}
void SFXNullVoice::setPosition( U32 sample )
{
_seek( sample );
}
void SFXNullVoice::setMinMaxDistance( F32 min, F32 max )
{
}
void SFXNullVoice::setVelocity( const VectorF& velocity )
{
}
void SFXNullVoice::setTransform( const MatrixF& transform )
{
}
void SFXNullVoice::setVolume( F32 volume )
{
}
void SFXNullVoice::setPitch( F32 pitch )
{
}
void SFXNullVoice::setCone( F32 innerAngle, F32 outerAngle, F32 outerVolume )
{
}

View file

@ -0,0 +1,86 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _SFXNULLVOICE_H_
#define _SFXNULLVOICE_H_
#ifndef _SFXVOICE_H_
#include "sfx/sfxVoice.h"
#endif
#ifndef _TIMESOURCE_H_
#include "core/util/timeSource.h"
#endif
class SFXNullBuffer;
class SFXNullVoice : public SFXVoice
{
public:
typedef SFXVoice Parent;
friend class SFXNullDevice;
protected:
typedef GenericTimeSource< VirtualMSTimer > TimeSource;
SFXNullVoice( SFXNullBuffer* buffer );
/// The virtual play timer.
mutable TimeSource mPlayTimer;
///
bool mIsLooping;
// SFXVoice.
virtual SFXStatus _status() const;
virtual void _play();
virtual void _pause();
virtual void _stop();
virtual void _seek( U32 sample );
virtual U32 _tell() const;
///
U32 _getPlayTime() const
{
return mPlayTimer.getPosition();
}
public:
virtual ~SFXNullVoice();
/// SFXVoice
SFXStatus getStatus() const;
void setPosition( U32 sample );
void play( bool looping );
void setMinMaxDistance( F32 min, F32 max );
void setVelocity( const VectorF& velocity );
void setTransform( const MatrixF& transform );
void setVolume( F32 volume );
void setPitch( F32 pitch );
void setCone( F32 innerAngle, F32 outerAngle, F32 outerVolume );
};
#endif // _SFXNULLVOICE_H_