Browse Source

display: Fix assorted unreachable code warnings

rdb 1 year ago
parent
commit
c4adc17d55
2 changed files with 14 additions and 23 deletions
  1. 7 8
      panda/metalibs/pandagl/pandagl.cxx
  2. 7 15
      panda/src/display/graphicsStateGuardian.cxx

+ 7 - 8
panda/metalibs/pandagl/pandagl.cxx

@@ -70,25 +70,24 @@ init_libpandagl() {
  */
 int
 get_pipe_type_pandagl() {
-#ifdef HAVE_WGL
+#if defined(HAVE_WGL)
   return wglGraphicsPipe::get_class_type().get_index();
-#endif
 
-#if defined(HAVE_COCOA)
+#elif defined(HAVE_COCOA)
   return CocoaGraphicsPipe::get_class_type().get_index();
+
 #elif defined(HAVE_CARBON)
   return osxGraphicsPipe::get_class_type().get_index();
-#endif
 
-#ifdef HAVE_GLX
+#elif defined(HAVE_GLX)
   return glxGraphicsPipe::get_class_type().get_index();
-#endif
 
-#ifdef HAVE_EGL
+#elif defined(HAVE_EGL)
   return eglGraphicsPipe::get_class_type().get_index();
-#endif
 
+#else
   return 0;
+#endif
 }
 
 #if defined(HAVE_EGL) && !defined(USE_X11)

+ 7 - 15
panda/src/display/graphicsStateGuardian.cxx

@@ -1907,6 +1907,8 @@ fetch_specified_texture(Shader::ShaderTexSpec &spec, SamplerState &sampler,
       const LightAttrib *target_light;
       _target_rs->get_attrib_def(target_light);
 
+      PT(Texture) tex;
+
       // We don't count ambient lights, which would be pretty silly to handle
       // via this mechanism.
       size_t num_lights = target_light->get_num_non_ambient_lights();
@@ -1916,28 +1918,21 @@ fetch_specified_texture(Shader::ShaderTexSpec &spec, SamplerState &sampler,
         Light *light_obj = light.node()->as_light();
         nassertr(light_obj != nullptr, nullptr);
 
-        PT(Texture) tex;
         LightLensNode *lln = DCAST(LightLensNode, light.node());
         if (lln != nullptr && lln->_shadow_caster) {
           tex = get_shadow_map(light);
         } else {
           tex = get_dummy_shadow_map((Texture::TextureType)spec._desired_type);
         }
-
-        if (tex != nullptr) {
-          sampler = tex->get_default_sampler();
-        }
-        return tex;
       } else {
         // There is no such light assigned.  Bind a dummy shadow map.
-        PT(Texture) tex = get_dummy_shadow_map((Texture::TextureType)spec._desired_type);
-        if (tex != nullptr) {
-          sampler = tex->get_default_sampler();
-        }
-        return tex;
+        tex = get_dummy_shadow_map((Texture::TextureType)spec._desired_type);
+      }
+      if (tex != nullptr) {
+        sampler = tex->get_default_sampler();
       }
+      return tex;
     }
-    break;
 
   case Shader::STO_ff_stage_i:
     {
@@ -2005,7 +2000,6 @@ fetch_specified_texture(Shader::ShaderTexSpec &spec, SamplerState &sampler,
       }
       return default_add_tex;
     }
-    break;
 
   case Shader::STO_stage_normal_i:
     {
@@ -2035,7 +2029,6 @@ fetch_specified_texture(Shader::ShaderTexSpec &spec, SamplerState &sampler,
       }
       return default_normal_height_tex;
     }
-    break;
 
   case Shader::STO_stage_gloss_i:
     {
@@ -2088,7 +2081,6 @@ fetch_specified_texture(Shader::ShaderTexSpec &spec, SamplerState &sampler,
       }
       return default_normal_height_tex;
     }
-    break;
 
   case Shader::STO_stage_selector_i:
     {