Przeglądaj źródła

Disabled Camera does not render.
Disabled SoundListener does not hear 3D sounds.

Lasse Öörni 12 lat temu
rodzic
commit
9be174c473

+ 2 - 0
Engine/Audio/SoundListener.cpp

@@ -43,6 +43,8 @@ SoundListener::~SoundListener()
 void SoundListener::RegisterObject(Context* context)
 void SoundListener::RegisterObject(Context* context)
 {
 {
     context->RegisterFactory<SoundListener>();
     context->RegisterFactory<SoundListener>();
+    
+    ACCESSOR_ATTRIBUTE(SoundListener, VAR_BOOL, "Is Enabled", IsEnabled, SetEnabled, bool, true, AM_DEFAULT);
 }
 }
 
 
 }
 }

+ 2 - 1
Engine/Audio/SoundSource3D.cpp

@@ -103,7 +103,8 @@ void SoundSource3D::CalculateAttenuation()
         SoundListener* listener = audio_->GetListener();
         SoundListener* listener = audio_->GetListener();
         
         
         // Listener must either be sceneless or in the same scene, else attenuate sound to silence
         // Listener must either be sceneless or in the same scene, else attenuate sound to silence
-        if (listener && listener->GetNode() && (!listener->GetScene() || listener->GetScene() == GetScene()))
+        if (listener && listener->GetNode() && listener->IsEnabledEffective() && (!listener->GetScene() ||
+            listener->GetScene() == GetScene()))
         {
         {
             Node* listenerNode = listener->GetNode();
             Node* listenerNode = listener->GetNode();
             Vector3 relativePos(listenerNode->GetWorldRotation().Inverse() * (node_->GetWorldPosition() - listenerNode->GetWorldPosition()));
             Vector3 relativePos(listenerNode->GetWorldRotation().Inverse() * (node_->GetWorldPosition() - listenerNode->GetWorldPosition()));

+ 1 - 0
Engine/Graphics/Camera.cpp

@@ -83,6 +83,7 @@ void Camera::RegisterObject(Context* context)
 {
 {
     context->RegisterFactory<Camera>();
     context->RegisterFactory<Camera>();
     
     
+    ACCESSOR_ATTRIBUTE(Camera, VAR_BOOL, "Is Enabled", IsEnabled, SetEnabled, bool, true, AM_DEFAULT);
     ACCESSOR_ATTRIBUTE(Camera, VAR_FLOAT, "Near Clip", GetNearClip, SetNearClip, float, DEFAULT_NEARCLIP, AM_DEFAULT);
     ACCESSOR_ATTRIBUTE(Camera, VAR_FLOAT, "Near Clip", GetNearClip, SetNearClip, float, DEFAULT_NEARCLIP, AM_DEFAULT);
     ACCESSOR_ATTRIBUTE(Camera, VAR_FLOAT, "Far Clip", GetFarClip, SetFarClip, float, DEFAULT_FARCLIP, AM_DEFAULT);
     ACCESSOR_ATTRIBUTE(Camera, VAR_FLOAT, "Far Clip", GetFarClip, SetFarClip, float, DEFAULT_FARCLIP, AM_DEFAULT);
     ACCESSOR_ATTRIBUTE(Camera, VAR_FLOAT, "FOV", GetFov, SetFov, float, DEFAULT_FOV, AM_DEFAULT);
     ACCESSOR_ATTRIBUTE(Camera, VAR_FLOAT, "FOV", GetFov, SetFov, float, DEFAULT_FOV, AM_DEFAULT);

+ 1 - 1
Engine/Graphics/View.cpp

@@ -276,7 +276,7 @@ bool View::Define(RenderSurface* renderTarget, Viewport* viewport)
 {
 {
     Scene* scene = viewport->GetScene();
     Scene* scene = viewport->GetScene();
     Camera* camera = viewport->GetCamera();
     Camera* camera = viewport->GetCamera();
-    if (!scene || !camera || !camera->GetNode())
+    if (!scene || !camera || !camera->GetNode() || !camera->IsEnabledEffective())
         return false;
         return false;
     
     
     // If scene is loading asynchronously, it is incomplete and should not be rendered
     // If scene is loading asynchronously, it is incomplete and should not be rendered