Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoerg Mueller <nexyon@gmail.com>2011-08-22 22:59:56 +0400
committerJoerg Mueller <nexyon@gmail.com>2011-08-22 22:59:56 +0400
commita71c215f228173070d41faef1321db25b40d723e (patch)
treef5b81a18f01c7dd8e7450e3c6fc823038b3c11da /source/gameengine/Ketsji/KX_SoundActuator.cpp
parentee40894c05b1d5f07eda671bad74f18605cde0b6 (diff)
3D Audio GSoC:
Final GSoC commit. * Bugfix: Negative frames crashed * Bugfix: JOS sample buffer size prediction error (wasted memory) * Optimisation: for JOS upsampling (around 12 % difference measured here) * Optimisation: Better filter for JOS resampling * Bugfix: Error in relative 3D audio code. * Removed Attenuation * Bugfix: Multiple scenes in BGE lead to errors, BGE audio now all relative, to support multiple scenes.
Diffstat (limited to 'source/gameengine/Ketsji/KX_SoundActuator.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp
index eb75e4944a7..6c7b515c095 100644
--- a/source/gameengine/Ketsji/KX_SoundActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp
@@ -46,6 +46,8 @@
#include "KX_GameObject.h"
#include "KX_PyMath.h" // needed for PyObjectFrom()
+#include "KX_PythonInit.h"
+#include "KX_Camera.h"
#include <iostream>
/* ------------------------------------------------------------------------- */
@@ -112,7 +114,7 @@ void KX_SoundActuator::play()
if(m_is3d && !handle3d.isNull())
{
- handle3d->setRelative(false);
+ handle3d->setRelative(true);
handle3d->setVolumeMaximum(m_3d.max_gain);
handle3d->setVolumeMinimum(m_3d.min_gain);
handle3d->setDistanceReference(m_3d.reference_distance);
@@ -222,16 +224,27 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
if(m_is3d && !handle3d.isNull())
{
- KX_GameObject* obj = (KX_GameObject*)this->GetParent();
- AUD_Vector3 v;
- float q[4];
-
- obj->NodeGetWorldPosition().getValue(v.get());
- handle3d->setSourceLocation(v);
- obj->GetLinearVelocity().getValue(v.get());
- handle3d->setSourceVelocity(v);
- obj->NodeGetWorldOrientation().getRotation().getValue(q);
- handle3d->setSourceOrientation(AUD_Quaternion(q[3], q[0], q[1], q[2]));
+ KX_Camera* cam = KX_GetActiveScene()->GetActiveCamera();
+ if (cam)
+ {
+ KX_GameObject* obj = (KX_GameObject*)this->GetParent();
+ MT_Point3 p;
+ MT_Matrix3x3 Mo;
+ AUD_Vector3 v;
+ float q[4];
+
+ Mo = cam->NodeGetWorldOrientation().inverse();
+ p = (obj->NodeGetWorldPosition() - cam->NodeGetWorldPosition());
+ p = Mo * p;
+ p.getValue(v.get());
+ handle3d->setSourceLocation(v);
+ p = (obj->GetLinearVelocity() - cam->GetLinearVelocity());
+ p = Mo * p;
+ p.getValue(v.get());
+ handle3d->setSourceVelocity(v);
+ (Mo * obj->NodeGetWorldOrientation()).getRotation().getValue(q);
+ handle3d->setSourceOrientation(AUD_Quaternion(q[3], q[0], q[1], q[2]));
+ }
}
result = true;
}