Skip to content

Commit

Permalink
support for Ogre-Next 3.0 and 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rpaciorek authored and paroj committed May 26, 2024
1 parent 25ea305 commit 2d37345
Show file tree
Hide file tree
Showing 23 changed files with 125 additions and 76 deletions.
12 changes: 6 additions & 6 deletions oggsound/include/OgreOggISound.h
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ namespace OgreOggSound
*/
void _getSharedProperties(BufferListPtr& buffers, float& length, ALenum& format);

#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
/** Gets name
*/
virtual Ogre::String getName();
Expand All @@ -532,7 +532,7 @@ namespace OgreOggSound
*/
OgreOggISound(
const Ogre::String& name
#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
, Ogre::SceneManager* scnMgr, Ogre::IdType id, Ogre::ObjectMemoryManager *objMemMgr, Ogre::uint8 renderQueueId
#endif
);
Expand Down Expand Up @@ -581,11 +581,11 @@ namespace OgreOggSound
*/
virtual void _notifyAttached(
Ogre::Node* node
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
, bool isTagPoint = false
#endif
);
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
/** Notifys object its been moved
@remarks
Overridden from MovableObject.
Expand All @@ -596,7 +596,7 @@ namespace OgreOggSound
*/
virtual void _updateRenderQueue(Ogre::RenderQueue *queue, Ogre::Camera *camera, const Ogre::Camera *lodCamera);
#endif
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
/** Renderable callback
@remarks
Overridden function from MovableObject.
Expand Down Expand Up @@ -683,7 +683,7 @@ namespace OgreOggSound
bool mGiveUpSource; // Flag to indicate whether sound should release its source when stopped
bool mStream; // Stream flag
bool mSourceRelative; // Relative position flag
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
bool mLocalTransformDirty; // Transformation update flag
#else
Ogre::Vector3 mPosition; // 3D position
Expand Down
18 changes: 9 additions & 9 deletions oggsound/include/OgreOggListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,24 @@ namespace OgreOggSound
Creates a listener object to act as the ears of the user.
*/
OgreOggListener(
#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
Ogre::IdType id, Ogre::SceneManager *scnMgr, Ogre::ObjectMemoryManager *objMemMgr, Ogre::uint8 renderQueueId
#else
Ogre::SceneManager* scnMgr = NULL
#endif
):
#if OGRE_VERSION_MAJOR == 2 && OGRE_VERSION_MINOR > 0
#if AV_OGRE_NEXT_VERSION >= 0x20100
MovableObject(id, objMemMgr, scnMgr, renderQueueId),
#endif
mVelocity(Ogre::Vector3::ZERO)
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
, mLocalTransformDirty(false)
#endif
, mSceneMgr(scnMgr)
{
for (int i=0; i<6; ++i ) mOrientation[i]=0.f;
mName = "OgreOggListener";
#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
setLocalAabb(Ogre::Aabb::BOX_NULL);
setQueryFlags(0);
#endif
Expand Down Expand Up @@ -107,7 +107,7 @@ namespace OgreOggSound
bounding radius for this object.
*/
virtual float getBoundingRadius(void) const;
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
void _updateRenderQueue(Ogre::RenderQueue *queue) override {}
void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables) override {}
#else
Expand All @@ -119,11 +119,11 @@ namespace OgreOggSound
*/
virtual void _notifyAttached(
Ogre::Node* node
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
, bool isTagPoint = false
#endif
);
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
/** Moved callback
@remarks
Overridden function from MovableObject.
Expand All @@ -137,7 +137,7 @@ namespace OgreOggSound
/** Returns scenemanager which created this listener.
*/
Ogre::SceneManager* getSceneManager() { return mSceneMgr; }
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
/** Sets scenemanager which created this listener.
*/
void setSceneManager(Ogre::SceneManager& m) { mSceneMgr=&m; }
Expand All @@ -153,7 +153,7 @@ namespace OgreOggSound
*/
Ogre::Vector3 mVelocity; // 3D velocity
float mOrientation[6]; // 3D orientation
#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
Ogre::Vector3 mPosition; // 3D position
Ogre::Quaternion mOrient; // 3D orientation as Quaternion
#else
Expand Down
2 changes: 1 addition & 1 deletion oggsound/include/OgreOggSound.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include "OgreOggSoundManager.h"

#ifndef OGRE_LOG_ERROR
#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
#define OGRE_LOG_ERROR(a) Ogre::LogManager::getSingleton().logMessage(Ogre::LML_CRITICAL, a)
#else
#define OGRE_LOG_ERROR(a) Ogre::LogManager::getSingleton().logError(a)
Expand Down
4 changes: 2 additions & 2 deletions oggsound/include/OgreOggSoundFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace OgreOggSound
{

protected:
#if OGRE_VERSION_MAJOR == 2 && OGRE_VERSION_MINOR > 0
#if AV_OGRE_NEXT_VERSION >= 0x20100
Ogre::MovableObject* createInstanceImpl(Ogre::IdType id, Ogre::ObjectMemoryManager *objectMemoryManager, Ogre::SceneManager* manager, const Ogre::NameValuePairList* params = 0);
#else
Ogre::MovableObject* createInstanceImpl(const Ogre::String& name, const Ogre::NameValuePairList* params);
Expand All @@ -55,7 +55,7 @@ namespace OgreOggSound

const Ogre::String& getType(void) const;

#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
void destroyInstance( Ogre::MovableObject* obj);
#endif
};
Expand Down
2 changes: 1 addition & 1 deletion oggsound/include/OgreOggSoundManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ namespace OgreOggSound

OgreOggISound* _createSoundImpl(
const Ogre::String& name,
#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
Ogre::IdType id,
#endif
const Ogre::String& file,
Expand Down
13 changes: 13 additions & 0 deletions oggsound/include/OgreOggSoundPrereqs.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@
#include <OgreMovableObject.h>
#include <OgreLogManager.h>

// set AV_OGRE_NEXT_VERSION to easy check Ogre version
// using separate define to avoid issue with `#define OGRE_NEXT_VERSION 0`
// and code using `#ifndef OGRE_NEXT_VERSION` to detect Ogre1
#ifdef OGRE_NEXT_VERSION
#define AV_OGRE_NEXT_VERSION OGRE_NEXT_VERSION
#else
#if OGRE_VERSION_MAJOR == 2
#define AV_OGRE_NEXT_VERSION OGRE_VERSION
#else
#define AV_OGRE_NEXT_VERSION 0
#endif
#endif

/**
* OGGSOUND_THREADED: Specifies whether to use threads for streaming
* 0 - No multithreading
Expand Down
2 changes: 1 addition & 1 deletion oggsound/include/OgreOggStaticSound.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace OgreOggSound
*/
OgreOggStaticSound(
const Ogre::String& name
#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
, Ogre::SceneManager* scnMgr, Ogre::IdType id, Ogre::ObjectMemoryManager *objMemMgr, Ogre::uint8 renderQueueId
#endif
);
Expand Down
2 changes: 1 addition & 1 deletion oggsound/include/OgreOggStaticWavSound.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ namespace OgreOggSound
*/
OgreOggStaticWavSound(
const Ogre::String& name
#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
, Ogre::SceneManager* scnMgr, Ogre::IdType id, Ogre::ObjectMemoryManager *objMemMgr, Ogre::uint8 renderQueueId
#endif
);
Expand Down
2 changes: 1 addition & 1 deletion oggsound/include/OgreOggStreamBufferSound.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ namespace OgreOggSound
*/
OgreOggStreamBufferSound(
const Ogre::String& name
#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
, Ogre::SceneManager* scnMgr, Ogre::IdType id, Ogre::ObjectMemoryManager *objMemMgr, Ogre::uint8 renderQueueId
#endif
);
Expand Down
2 changes: 1 addition & 1 deletion oggsound/include/OgreOggStreamSound.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace OgreOggSound
*/
OgreOggStreamSound(
const Ogre::String& name
#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
, Ogre::SceneManager* scnMgr, Ogre::IdType id, Ogre::ObjectMemoryManager *objMemMgr, Ogre::uint8 renderQueueId
#endif
);
Expand Down
2 changes: 1 addition & 1 deletion oggsound/include/OgreOggStreamWavSound.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace OgreOggSound
*/
OgreOggStreamWavSound(
const Ogre::String& name
#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
, Ogre::SceneManager* scnMgr, Ogre::IdType id, Ogre::ObjectMemoryManager *objMemMgr, Ogre::uint8 renderQueueId
#endif
);
Expand Down
22 changes: 11 additions & 11 deletions oggsound/src/OgreOggISound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ namespace OgreOggSound
/*/////////////////////////////////////////////////////////////////*/
OgreOggISound::OgreOggISound(
const Ogre::String& name
#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
, Ogre::SceneManager* scnMgr, Ogre::IdType id, Ogre::ObjectMemoryManager *objMemMgr, Ogre::uint8 renderQueueId
#endif
) :
#if OGRE_VERSION_MAJOR == 2 && OGRE_VERSION_MINOR > 0
#if AV_OGRE_NEXT_VERSION >= 0x20100
MovableObject(id, objMemMgr, scnMgr, renderQueueId),
mPosition(0,0,0),
mDirection(0,0,0),
Expand Down Expand Up @@ -115,7 +115,7 @@ namespace OgreOggSound
,mAudioOffset(0)
,mAudioEnd(0)
,mLoopOffset(0)
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
,mLocalTransformDirty(true)
#endif
,mDisable3D(false)
Expand All @@ -132,7 +132,7 @@ namespace OgreOggSound
mOggCallbacks.seek_func = OOSStreamSeek;
mOggCallbacks.tell_func = OOSStreamTell;
mBuffers.reset();
#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
setLocalAabb(Ogre::Aabb::BOX_NULL);
setQueryFlags(0);
#endif
Expand All @@ -143,7 +143,7 @@ namespace OgreOggSound
OgreOggSoundManager::getSingletonPtr()->_releaseSoundImpl(this);
}
/*/////////////////////////////////////////////////////////////////*/
#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
Ogre::String OgreOggISound::getName() {
return mName;
}
Expand Down Expand Up @@ -657,7 +657,7 @@ namespace OgreOggSound
/*/////////////////////////////////////////////////////////////////*/
void OgreOggISound::update(float fTime)
{
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
if (mLocalTransformDirty)
{
Ogre::Vector3 position(0, 0, 0);
Expand Down Expand Up @@ -717,20 +717,20 @@ namespace OgreOggSound
/*/////////////////////////////////////////////////////////////////*/
void OgreOggISound::_notifyAttached(
Ogre::Node* node
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
, bool isTagPoint
#endif
)
{
// Call base class notify
Ogre::MovableObject::_notifyAttached(
node
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
, isTagPoint
#endif
);

#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
// Immediately set position/orientation when attached
mLocalTransformDirty = true;
#endif
Expand All @@ -740,7 +740,7 @@ namespace OgreOggSound
return;
}
/*/////////////////////////////////////////////////////////////////*/
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
void OgreOggISound::_notifyMoved(void)
{
// Call base class notify
Expand All @@ -752,7 +752,7 @@ namespace OgreOggSound
void OgreOggISound::_updateRenderQueue(Ogre::RenderQueue *queue, Ogre::Camera *camera, const Ogre::Camera *lodCamera) {
}
#endif
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
/*/////////////////////////////////////////////////////////////////*/
void OgreOggISound::visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables)
{
Expand Down
10 changes: 5 additions & 5 deletions oggsound/src/OgreOggListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace OgreOggSound
/*/////////////////////////////////////////////////////////////////*/
void OgreOggListener::update()
{
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
if(mLocalTransformDirty)
{
if ( mParentNode )
Expand Down Expand Up @@ -111,23 +111,23 @@ namespace OgreOggSound
/*/////////////////////////////////////////////////////////////////*/
void OgreOggListener::_notifyAttached(
Ogre::Node* node
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
, bool isTagPoint
#endif
)
{
// Call base class notify
Ogre::MovableObject::_notifyAttached(
node
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
, isTagPoint
#endif
);

// Immediately set position/orientation when attached
if (mParentNode)
{
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
mLocalTransformDirty = true;
#endif
update();
Expand All @@ -136,7 +136,7 @@ namespace OgreOggSound
return;
}
/*/////////////////////////////////////////////////////////////////*/
#if OGRE_VERSION_MAJOR != 2
#if !AV_OGRE_NEXT_VERSION
void OgreOggListener::_notifyMoved(void)
{
// Call base class notify
Expand Down
8 changes: 4 additions & 4 deletions oggsound/src/OgreOggSoundFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ namespace OgreOggSound
return FACTORY_TYPE_NAME;
}
//-----------------------------------------------------------------------
#if OGRE_VERSION_MAJOR == 2 && OGRE_VERSION_MINOR > 0
#if AV_OGRE_NEXT_VERSION >= 0x20100
Ogre::MovableObject* OgreOggSoundFactory::createInstanceImpl(Ogre::IdType id, Ogre::ObjectMemoryManager *objectMemoryManager, Ogre::SceneManager* manager, const Ogre::NameValuePairList* params)
#else
Ogre::MovableObject* OgreOggSoundFactory::createInstanceImpl(const Ogre::String& name, const Ogre::NameValuePairList* params)
#endif
{
Ogre::String fileName;
#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
Ogre::String reName = Ogre::BLANKSTRING;
#else
Ogre::String reName = name;
Expand Down Expand Up @@ -113,7 +113,7 @@ namespace OgreOggSound
"OgreOggSoundFactory::createInstance");
}

#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
return OgreOggSoundManager::getSingletonPtr()->_createSoundImpl(reName, id, fileName, stream, loop, preBuffer, immediate);
#else
return OgreOggSoundManager::getSingletonPtr()->_createSoundImpl(reName, fileName, stream, loop, preBuffer, immediate);
Expand All @@ -123,7 +123,7 @@ namespace OgreOggSound
return 0;
}

#if OGRE_VERSION_MAJOR == 2
#if AV_OGRE_NEXT_VERSION >= 0x20000
void OgreOggSoundFactory::destroyInstance( Ogre::MovableObject* obj)
{
if ( dynamic_cast<OgreOggListener*>(obj) )
Expand Down
Loading

0 comments on commit 2d37345

Please sign in to comment.