|
@@ -202,6 +202,8 @@ SceneObject::SceneObject() :
|
|
VECTOR_SET_ASSOCIATION( mCollisionFixtureDefs );
|
|
VECTOR_SET_ASSOCIATION( mCollisionFixtureDefs );
|
|
VECTOR_SET_ASSOCIATION( mCollisionFixtures );
|
|
VECTOR_SET_ASSOCIATION( mCollisionFixtures );
|
|
VECTOR_SET_ASSOCIATION( mAttachedCtrls );
|
|
VECTOR_SET_ASSOCIATION( mAttachedCtrls );
|
|
|
|
+ VECTOR_SET_ASSOCIATION( mAudioHandles );
|
|
|
|
+ VECTOR_SET_ASSOCIATION( mHandleDeletionList );
|
|
|
|
|
|
// Assign scene-object index.
|
|
// Assign scene-object index.
|
|
mSerialId = ++sSceneObjectMasterSerialId;
|
|
mSerialId = ++sSceneObjectMasterSerialId;
|
|
@@ -256,6 +258,16 @@ SceneObject::~SceneObject()
|
|
mpScene->removeFromScene( this );
|
|
mpScene->removeFromScene( this );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (mAudioHandles.size())
|
|
|
|
+ {
|
|
|
|
+ for (typeAudioHandleVector::iterator itr = mAudioHandles.begin(); itr != mAudioHandles.end(); ++itr)
|
|
|
|
+ {
|
|
|
|
+ U32 handle = *itr;
|
|
|
|
+ alxStop(handle);
|
|
|
|
+ }
|
|
|
|
+ mAudioHandles.clear();
|
|
|
|
+ }
|
|
|
|
+
|
|
// Decrease scene-object count.
|
|
// Decrease scene-object count.
|
|
--sGlobalSceneObjectCount;
|
|
--sGlobalSceneObjectCount;
|
|
}
|
|
}
|
|
@@ -563,6 +575,9 @@ void SceneObject::preIntegrate( const F32 totalTime, const F32 elapsedTime, Debu
|
|
updateSize(elapsedTime);
|
|
updateSize(elapsedTime);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (mAudioHandles.size())
|
|
|
|
+ refreshsources();
|
|
|
|
+
|
|
// Finish if nothing is dirty.
|
|
// Finish if nothing is dirty.
|
|
if ( !mSpatialDirty )
|
|
if ( !mSpatialDirty )
|
|
return;
|
|
return;
|
|
@@ -640,6 +655,17 @@ void SceneObject::integrateObject( const F32 totalTime, const F32 elapsedTime, D
|
|
{
|
|
{
|
|
updateBlendColor( elapsedTime );
|
|
updateBlendColor( elapsedTime );
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (mAudioHandles.size())
|
|
|
|
+ {
|
|
|
|
+ for (typeAudioHandleVector::iterator itr = mAudioHandles.begin(); itr != mAudioHandles.end(); ++itr)
|
|
|
|
+ {
|
|
|
|
+ U32 handle = *itr;
|
|
|
|
+ Point2F vel = getLinearVelocity();
|
|
|
|
+ alxSource3f(handle, AL_POSITION, position.x, position.y, 0.f);
|
|
|
|
+ alxSource3f(handle, AL_VELOCITY, vel.x, vel.y, 0.f);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
@@ -861,6 +887,24 @@ void SceneObject::sceneRenderOverlay( const SceneRenderState* sceneRenderState )
|
|
{
|
|
{
|
|
pScene->mDebugDraw.DrawSortPoint( getRenderPosition(), getSize(), mSortPoint );
|
|
pScene->mDebugDraw.DrawSortPoint( getRenderPosition(), getSize(), mSortPoint );
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (debugMask & Scene::SCENE_DEBUG_AUDIO_SOURCES)
|
|
|
|
+ {
|
|
|
|
+ if (mAudioHandles.size())
|
|
|
|
+ {
|
|
|
|
+ for (typeAudioHandleVector::iterator itr = mAudioHandles.begin(); itr != mAudioHandles.end(); ++itr)
|
|
|
|
+ {
|
|
|
|
+ U32 handle = *itr;
|
|
|
|
+ ALfloat MaxDistance = 0.f;
|
|
|
|
+ ALfloat RefDistance = 0.f;
|
|
|
|
+ alxGetSourcef(handle, AL_MAX_DISTANCE, &MaxDistance);
|
|
|
|
+ alxGetSourcef(handle, AL_REFERENCE_DISTANCE, &RefDistance);
|
|
|
|
+ pScene->mDebugDraw.DrawCircle(getRenderPosition(), MaxDistance, ColorF(1.f, 0.2f, 0.2f));
|
|
|
|
+ pScene->mDebugDraw.DrawCircle(getRenderPosition(), RefDistance, ColorF(1.f, 0.0f, 0.0f));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
@@ -4030,6 +4074,56 @@ bool SceneObject::writeField(StringTableEntry fieldname, const char* value)
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void SceneObject::addAudioHandle(AUDIOHANDLE handle)
|
|
|
|
+{
|
|
|
|
+ mAudioHandles.push_back_unique(handle);
|
|
|
|
+ Con::printf("New Vector size : %i", mAudioHandles.size());
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+S32 SceneObject::getSoundsCount(void)
|
|
|
|
+{
|
|
|
|
+ return mAudioHandles.size();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+U32 SceneObject::getSound(S32 index)
|
|
|
|
+{
|
|
|
|
+ if (mAudioHandles.size() - 1 < index)
|
|
|
|
+ return NULL_AUDIOHANDLE;
|
|
|
|
+ U32 handle = mAudioHandles[index];
|
|
|
|
+ return handle;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void SceneObject::refreshsources()
|
|
|
|
+{
|
|
|
|
+ if (mAudioHandles.size())
|
|
|
|
+ {
|
|
|
|
+ S32 index = 0;
|
|
|
|
+ for (typeAudioHandleVector::iterator itr = mAudioHandles.begin(); itr != mAudioHandles.end(); ++itr)
|
|
|
|
+ {
|
|
|
|
+ U32 handle = *itr;
|
|
|
|
+
|
|
|
|
+ if (handle) {
|
|
|
|
+
|
|
|
|
+ if (!alxIsValidHandle(handle))
|
|
|
|
+ mHandleDeletionList.push_back(index);
|
|
|
|
+
|
|
|
|
+ index++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (mHandleDeletionList.size())
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ for (Vector<S32>::iterator delitr = mHandleDeletionList.begin(); delitr != mHandleDeletionList.end(); ++delitr)
|
|
|
|
+ {
|
|
|
|
+ mAudioHandles.erase(*delitr);
|
|
|
|
+ }
|
|
|
|
+ mHandleDeletionList.clear();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
//------------------------------------------------------------------------------
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
S32 QSORT_CALLBACK SceneObject::sceneObjectLayerDepthSort(const void* a, const void* b)
|
|
S32 QSORT_CALLBACK SceneObject::sceneObjectLayerDepthSort(const void* a, const void* b)
|