Browse Source

Merge remote-tracking branch 'upstream/master' into cmake

Sam Edwards 11 years ago
parent
commit
a85d1f4cc2
34 changed files with 323 additions and 96 deletions
  1. 2 2
      dtool/src/cppparser/cppManifest.cxx
  2. 2 0
      dtool/src/dtoolbase/dtoolbase_cc.h
  3. 1 1
      dtool/src/dtoolbase/typeHandle.h
  4. 2 2
      dtool/src/dtoolutil/filename.cxx
  5. 1 1
      dtool/src/dtoolutil/globPattern.cxx
  6. 6 0
      dtool/src/interrogate/interfaceMakerPythonNative.cxx
  7. 3 0
      dtool/src/interrogate/typeManager.cxx
  8. 10 9
      makepanda/makepanda.py
  9. 18 15
      makepanda/makepandacore.py
  10. 1 1
      panda/src/collide/collisionPolygon.cxx
  11. 1 1
      panda/src/display/subprocessWindow.cxx
  12. 1 1
      panda/src/downloader/bioStreamBuf.cxx
  13. 4 0
      panda/src/event/buttonEvent.cxx
  14. 5 3
      panda/src/glstuff/glCgShaderContext_src.cxx
  15. 7 1
      panda/src/glstuff/glGraphicsBuffer_src.cxx
  16. 64 3
      panda/src/glstuff/glGraphicsStateGuardian_src.cxx
  17. 3 0
      panda/src/glstuff/glShaderContext_src.cxx
  18. 1 1
      panda/src/glstuff/glTextureContext_src.h
  19. 2 2
      panda/src/grutil/geoMipTerrain.cxx
  20. 2 2
      panda/src/grutil/rigidBodyCombiner.cxx
  21. 10 6
      panda/src/mathutil/triangulator.cxx
  22. 17 9
      panda/src/nativenet/buffered_datagramconnection.h
  23. 7 4
      panda/src/pgraph/loader.cxx
  24. 1 1
      panda/src/pgraph/loaderFileType.cxx
  25. 1 1
      panda/src/pgraph/modelSaveRequest.I
  26. 3 0
      panda/src/pnmimage/pfmFile.cxx
  27. 4 4
      panda/src/pnmimagetypes/pnmFileTypePNM.cxx
  28. 20 3
      panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx
  29. 2 1
      pandatool/src/maya/maya_funcs.cxx
  30. 4 4
      pandatool/src/mayaegg/mayaEggLoader.cxx
  31. 108 18
      pandatool/src/mayaegg/mayaToEggConverter.cxx
  32. 3 0
      pandatool/src/mayaegg/mayaToEggConverter.h
  33. 6 0
      pandatool/src/mayaprogs/mayaToEgg.cxx
  34. 1 0
      pandatool/src/mayaprogs/mayaToEgg.h

+ 2 - 2
dtool/src/cppparser/cppManifest.cxx

@@ -263,7 +263,7 @@ output(ostream &out) const {
     }
     }
 
 
     if ((*ei)._parm_number >= 0) {
     if ((*ei)._parm_number >= 0) {
-      if (stringify) {
+      if ((*ei)._stringify) {
         out << "#";
         out << "#";
       }
       }
       if ((*ei)._parm_number == _variadic_param) {
       if ((*ei)._parm_number == _variadic_param) {
@@ -345,7 +345,7 @@ save_expansion(const string &exp, const vector_string &parameter_names) {
       // Here's the start of an identifier.  Find the end of it.
       // Here's the start of an identifier.  Find the end of it.
       size_t q = p;
       size_t q = p;
       p++;
       p++;
-      while (p < exp.size() && isalnum(exp[p]) || exp[p] == '_') {
+      while (p < exp.size() && (isalnum(exp[p]) || exp[p] == '_')) {
         p++;
         p++;
       }
       }
 
 

+ 2 - 0
dtool/src/dtoolbase/dtoolbase_cc.h

@@ -123,6 +123,8 @@ typedef ios::seekdir ios_seekdir;
 #if defined(__has_extension) // Clang magic.
 #if defined(__has_extension) // Clang magic.
 #if __has_extension(cxx_constexpr)
 #if __has_extension(cxx_constexpr)
 #define CONSTEXPR constexpr
 #define CONSTEXPR constexpr
+#else
+#define CONSTEXPR INLINE
 #endif
 #endif
 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && (__cplusplus >= 201103L)
 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && (__cplusplus >= 201103L)
 #define CONSTEXPR constexpr
 #define CONSTEXPR constexpr

+ 1 - 1
dtool/src/dtoolbase/typeHandle.h

@@ -138,7 +138,7 @@ PUBLISHED:
   void inc_memory_usage(MemoryClass memory_class, int size);
   void inc_memory_usage(MemoryClass memory_class, int size);
   void dec_memory_usage(MemoryClass memory_class, int size);
   void dec_memory_usage(MemoryClass memory_class, int size);
 #else
 #else
-  CONSTEXPR int get_memory_usage(MemoryClass) const { return 0; }
+  static CONSTEXPR int get_memory_usage(MemoryClass) { return 0; }
   INLINE void inc_memory_usage(MemoryClass, int) { }
   INLINE void inc_memory_usage(MemoryClass, int) { }
   INLINE void dec_memory_usage(MemoryClass, int) { }
   INLINE void dec_memory_usage(MemoryClass, int) { }
 #endif  // DO_MEMORY_USAGE
 #endif  // DO_MEMORY_USAGE

+ 2 - 2
dtool/src/dtoolutil/filename.cxx

@@ -3059,7 +3059,7 @@ atomic_compare_and_exchange_contents(string &orig_contents,
     return false;
     return false;
   }
   }
     
     
-  size_t bytes_read = read(fd, buf, buf_size);
+  ssize_t bytes_read = read(fd, buf, buf_size);
   while (bytes_read > 0) {
   while (bytes_read > 0) {
     orig_contents += string(buf, bytes_read);
     orig_contents += string(buf, bytes_read);
     bytes_read = read(fd, buf, buf_size);
     bytes_read = read(fd, buf, buf_size);
@@ -3180,7 +3180,7 @@ atomic_read_contents(string &contents) const {
     return false;
     return false;
   }
   }
     
     
-  size_t bytes_read = read(fd, buf, buf_size);
+  ssize_t bytes_read = read(fd, buf, buf_size);
   while (bytes_read > 0) {
   while (bytes_read > 0) {
     contents += string(buf, bytes_read);
     contents += string(buf, bytes_read);
     bytes_read = read(fd, buf, buf_size);
     bytes_read = read(fd, buf, buf_size);

+ 1 - 1
dtool/src/dtoolutil/globPattern.cxx

@@ -370,7 +370,7 @@ matches_set(string::const_iterator &pi, string::const_iterator pend,
         char end = (*pi);
         char end = (*pi);
         ++pi;
         ++pi;
 
 
-        if (ch >= start && ch <= end || 
+        if ((ch >= start && ch <= end) || 
             (!_case_sensitive && 
             (!_case_sensitive && 
              ((tolower(ch) >= start && tolower(ch) <= end) ||
              ((tolower(ch) >= start && tolower(ch) <= end) ||
               (toupper(ch) >= start && toupper(ch) <= end)))) {
               (toupper(ch) >= start && toupper(ch) <= end)))) {

+ 6 - 0
dtool/src/interrogate/interfaceMakerPythonNative.cxx

@@ -2452,6 +2452,9 @@ write_function_for_top(ostream &out, InterfaceMaker::Object *obj, InterfaceMaker
   case AT_single_arg:
   case AT_single_arg:
     fname += ", PyObject *arg";
     fname += ", PyObject *arg";
     break;
     break;
+
+  default:
+    break;
   }
   }
   fname += ")";
   fname += ")";
 
 
@@ -3499,6 +3502,9 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj,
         ++open_scopes;
         ++open_scopes;
         indent_level += 2;
         indent_level += 2;
       }
       }
+
+    default:
+      break;
     }
     }
   }
   }
 
 

+ 3 - 0
dtool/src/interrogate/typeManager.cxx

@@ -1644,6 +1644,9 @@ get_template_parameter_type(CPPType *source_type, int i) {
 
 
   case CPPDeclaration::ST_reference:
   case CPPDeclaration::ST_reference:
     return get_template_parameter_type(source_type->as_reference_type()->_pointing_at, i);
     return get_template_parameter_type(source_type->as_reference_type()->_pointing_at, i);
+
+  default:
+    break;
   }
   }
 
 
   CPPStructType *type = source_type->as_struct_type();
   CPPStructType *type = source_type->as_struct_type();

+ 10 - 9
makepanda/makepanda.py

@@ -3837,15 +3837,16 @@ if (PkgSkip("OPENSSL")==0 and not RTDIST and not RUNTIME and PkgSkip("DEPLOYTOOL
   TargetAdd('build_patch.exe', input=COMMON_PANDA_LIBS_PYSTUB)
   TargetAdd('build_patch.exe', input=COMMON_PANDA_LIBS_PYSTUB)
   TargetAdd('build_patch.exe', opts=OPTS)
   TargetAdd('build_patch.exe', opts=OPTS)
 
 
-  TargetAdd('check_adler_check_adler.obj', opts=OPTS, input='check_adler.cxx')
-  TargetAdd('check_adler.exe', input=['check_adler_check_adler.obj'])
-  TargetAdd('check_adler.exe', input=COMMON_PANDA_LIBS_PYSTUB)
-  TargetAdd('check_adler.exe', opts=OPTS)
-
-  TargetAdd('check_crc_check_crc.obj', opts=OPTS, input='check_crc.cxx')
-  TargetAdd('check_crc.exe', input=['check_crc_check_crc.obj'])
-  TargetAdd('check_crc.exe', input=COMMON_PANDA_LIBS_PYSTUB)
-  TargetAdd('check_crc.exe', opts=OPTS)
+  if not PkgSkip("ZLIB"):
+    TargetAdd('check_adler_check_adler.obj', opts=OPTS, input='check_adler.cxx')
+    TargetAdd('check_adler.exe', input=['check_adler_check_adler.obj'])
+    TargetAdd('check_adler.exe', input=COMMON_PANDA_LIBS_PYSTUB)
+    TargetAdd('check_adler.exe', opts=OPTS)
+
+    TargetAdd('check_crc_check_crc.obj', opts=OPTS, input='check_crc.cxx')
+    TargetAdd('check_crc.exe', input=['check_crc_check_crc.obj'])
+    TargetAdd('check_crc.exe', input=COMMON_PANDA_LIBS_PYSTUB)
+    TargetAdd('check_crc.exe', opts=OPTS)
 
 
   TargetAdd('check_md5_check_md5.obj', opts=OPTS, input='check_md5.cxx')
   TargetAdd('check_md5_check_md5.obj', opts=OPTS, input='check_md5.cxx')
   TargetAdd('check_md5.exe', input=['check_md5_check_md5.obj'])
   TargetAdd('check_md5.exe', input=['check_md5_check_md5.obj'])

+ 18 - 15
makepanda/makepandacore.py

@@ -1536,20 +1536,18 @@ def SmartPkgEnable(pkg, pkgconfig = None, libs = None, incs = None, defs = None,
         return
         return
 
 
     elif (GetHost() == "darwin" and framework != None):
     elif (GetHost() == "darwin" and framework != None):
-        if (os.path.isdir("/Library/Frameworks/%s.framework" % framework) or
-            os.path.isdir("/System/Library/Frameworks/%s.framework" % framework) or
-            os.path.isdir("/Developer/Library/Frameworks/%s.framework" % framework) or
-            os.path.isdir("/Users/%s/System/Library/Frameworks/%s.framework" % (getpass.getuser(), framework))):
+        prefix = SDK["MACOSX"]
+        if (os.path.isdir(prefix + "/Library/Frameworks/%s.framework" % framework) or
+            os.path.isdir(prefix + "/System/Library/Frameworks/%s.framework" % framework) or
+            os.path.isdir(prefix + "/Developer/Library/Frameworks/%s.framework" % framework) or
+            os.path.isdir(prefix + "/Users/%s/System/Library/Frameworks/%s.framework" % (getpass.getuser(), framework))):
             LibName(target_pkg, "-framework " + framework)
             LibName(target_pkg, "-framework " + framework)
             for d, v in defs.values():
             for d, v in defs.values():
                 DefSymbol(target_pkg, d, v)
                 DefSymbol(target_pkg, d, v)
-        elif (pkg in PkgListGet()):
-            print("%sWARNING:%s Could not locate framework %s, excluding from build" % (GetColor("red"), GetColor(), framework))
-            PkgDisable(pkg)
-        else:
-            print("%sERROR:%s Could not locate framework %s, aborting build" % (GetColor("red"), GetColor(), framework))
-            exit()
-        return
+            return
+
+        elif VERBOSE:
+            print(ColorText("cyan", "Couldn't find the framework %s" % (framework)))
 
 
     elif (LocateBinary(tool) != None and (tool != "pkg-config" or pkgconfig != None)):
     elif (LocateBinary(tool) != None and (tool != "pkg-config" or pkgconfig != None)):
         if (isinstance(pkgconfig, str) or tool != "pkg-config"):
         if (isinstance(pkgconfig, str) or tool != "pkg-config"):
@@ -2280,10 +2278,15 @@ def SetupBuildEnvironment(compiler):
         # Invoke gcc to determine the system library directories.
         # Invoke gcc to determine the system library directories.
         global SYS_LIB_DIRS
         global SYS_LIB_DIRS
 
 
-        # gcc doesn't add this one, but we do want it:
-        local_lib = SDK.get("SYSROOT", "") + "/usr/local/lib"
-        if os.path.isdir(local_lib):
-            SYS_LIB_DIRS.append(local_lib)
+        if sys.platform == "darwin":
+            # We need to add this one explicitly.
+            SYS_LIB_DIRS.append(SDK["MACOSX"] + "/usr/lib")
+
+        if not SDK.get("MACOSX"):
+            # gcc doesn't add this one, but we do want it:
+            local_lib = SDK.get("SYSROOT", "") + "/usr/local/lib"
+            if os.path.isdir(local_lib):
+                SYS_LIB_DIRS.append(local_lib)
 
 
         cmd = GetCXX() + " -print-search-dirs"
         cmd = GetCXX() + " -print-search-dirs"
 
 

+ 1 - 1
panda/src/collide/collisionPolygon.cxx

@@ -474,7 +474,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const {
 
 
   LVector3 normal = (has_effective_normal() && sphere->get_respect_effective_normal()) ? get_effective_normal() : get_normal();
   LVector3 normal = (has_effective_normal() && sphere->get_respect_effective_normal()) ? get_effective_normal() : get_normal();
 #ifndef NDEBUG
 #ifndef NDEBUG
-  if (!IS_THRESHOLD_EQUAL(normal.length_squared(), 1.0f, 0.001), NULL) {
+  if (!IS_THRESHOLD_EQUAL(normal.length_squared(), 1.0f, 0.001)) {
     collide_cat.info()
     collide_cat.info()
       << "polygon within " << entry.get_into_node_path()
       << "polygon within " << entry.get_into_node_path()
       << " has normal " << normal << " of length " << normal.length()
       << " has normal " << normal << " of length " << normal.length()

+ 1 - 1
panda/src/display/subprocessWindow.cxx

@@ -574,7 +574,7 @@ translate_key(int &keycode, int os_code, unsigned int flags) const {
     keycode = os_code & 0xff;
     keycode = os_code & 0xff;
   }
   }
   
   
-#endif __APPLE__
+#endif  // __APPLE__
 
 
   return nk;
   return nk;
 }
 }

+ 1 - 1
panda/src/downloader/bioStreamBuf.cxx

@@ -198,7 +198,7 @@ underflow() {
 #ifdef IS_OSX
 #ifdef IS_OSX
         // occassionally we get -1 on read_open on the mac
         // occassionally we get -1 on read_open on the mac
         // the os_error is 35 which means "Resource temporarily unavailable".
         // the os_error is 35 which means "Resource temporarily unavailable".
-        if ( (_read_open == -1) && (os_error == 35)) {
+        if (!_read_open && os_error == 35) {
           downloader_cat.warning() << "forcing retry to true again and _read_open to true\n";
           downloader_cat.warning() << "forcing retry to true again and _read_open to true\n";
           BIO_set_retry_read(*_source);
           BIO_set_retry_read(*_source);
           _read_open = true;
           _read_open = true;

+ 4 - 0
panda/src/event/buttonEvent.cxx

@@ -79,6 +79,8 @@ write_datagram(Datagram &dg) const {
   case T_resume_down:
   case T_resume_down:
   case T_up:
   case T_up:
   case T_repeat:
   case T_repeat:
+  case T_raw_down:
+  case T_raw_up:
     // We write the button name.  This is not particularly compact, but
     // We write the button name.  This is not particularly compact, but
     // presumably we don't get thousands of button events per frame, and
     // presumably we don't get thousands of button events per frame, and
     // it is robust as the button index may change between sessions but
     // it is robust as the button index may change between sessions but
@@ -118,6 +120,8 @@ read_datagram(DatagramIterator &scan) {
   case T_resume_down:
   case T_resume_down:
   case T_up:
   case T_up:
   case T_repeat:
   case T_repeat:
+  case T_raw_down:
+  case T_raw_up:
     _button = ButtonRegistry::ptr()->get_button(scan.get_string());
     _button = ButtonRegistry::ptr()->get_button(scan.get_string());
     break;
     break;
 
 

+ 5 - 3
panda/src/glstuff/glCgShaderContext_src.cxx

@@ -262,19 +262,20 @@ issue_parameters(int altered) {
         switch(_ptr._info._class) {
         switch(_ptr._info._class) {
         case Shader::SAC_scalar: cgSetParameter1fv(p,(float*)ptr_data->_ptr); continue;
         case Shader::SAC_scalar: cgSetParameter1fv(p,(float*)ptr_data->_ptr); continue;
         case Shader::SAC_vector:
         case Shader::SAC_vector:
-          switch(_ptr._info._type) {
+          switch (_ptr._info._type) {
           case Shader::SAT_vec1: cgSetParameter1fv(p,(float*)ptr_data->_ptr); continue;
           case Shader::SAT_vec1: cgSetParameter1fv(p,(float*)ptr_data->_ptr); continue;
           case Shader::SAT_vec2: cgSetParameter2fv(p,(float*)ptr_data->_ptr); continue;
           case Shader::SAT_vec2: cgSetParameter2fv(p,(float*)ptr_data->_ptr); continue;
           case Shader::SAT_vec3: cgSetParameter3fv(p,(float*)ptr_data->_ptr); continue;
           case Shader::SAT_vec3: cgSetParameter3fv(p,(float*)ptr_data->_ptr); continue;
           case Shader::SAT_vec4: cgSetParameter4fv(p,(float*)ptr_data->_ptr); continue;
           case Shader::SAT_vec4: cgSetParameter4fv(p,(float*)ptr_data->_ptr); continue;
+          default: nassertd(false) continue;
           }
           }
         case Shader::SAC_matrix: cgGLSetMatrixParameterfc(p,(float*)ptr_data->_ptr); continue;
         case Shader::SAC_matrix: cgGLSetMatrixParameterfc(p,(float*)ptr_data->_ptr); continue;
         case Shader::SAC_array: {
         case Shader::SAC_array: {
-          switch(_ptr._info._subclass) {
+          switch (_ptr._info._subclass) {
           case Shader::SAC_scalar:
           case Shader::SAC_scalar:
             cgGLSetParameterArray1f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue;
             cgGLSetParameterArray1f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue;
           case Shader::SAC_vector:
           case Shader::SAC_vector:
-            switch(_ptr._dim[2]) {
+            switch (_ptr._dim[2]) {
             case 1: cgGLSetParameterArray1f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue;
             case 1: cgGLSetParameterArray1f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue;
             case 2: cgGLSetParameterArray2f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue;
             case 2: cgGLSetParameterArray2f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue;
             case 3: cgGLSetParameterArray3f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue;
             case 3: cgGLSetParameterArray3f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue;
@@ -294,6 +295,7 @@ issue_parameters(int altered) {
           case Shader::SAT_vec2: cgSetParameter2dv(p,(double*)ptr_data->_ptr); continue;
           case Shader::SAT_vec2: cgSetParameter2dv(p,(double*)ptr_data->_ptr); continue;
           case Shader::SAT_vec3: cgSetParameter3dv(p,(double*)ptr_data->_ptr); continue;
           case Shader::SAT_vec3: cgSetParameter3dv(p,(double*)ptr_data->_ptr); continue;
           case Shader::SAT_vec4: cgSetParameter4dv(p,(double*)ptr_data->_ptr); continue;
           case Shader::SAT_vec4: cgSetParameter4dv(p,(double*)ptr_data->_ptr); continue;
+          default: nassertd(false) continue;
           }
           }
         case Shader::SAC_matrix: cgGLSetMatrixParameterdc(p,(double*)ptr_data->_ptr); continue;
         case Shader::SAC_matrix: cgGLSetMatrixParameterdc(p,(double*)ptr_data->_ptr); continue;
         case Shader::SAC_array: {
         case Shader::SAC_array: {

+ 7 - 1
panda/src/glstuff/glGraphicsBuffer_src.cxx

@@ -1003,6 +1003,9 @@ bind_slot_multisample(bool rb_resize, Texture **attach, RenderTexturePlane slot,
           case Texture::F_depth_component32:
           case Texture::F_depth_component32:
             format = GL_DEPTH_COMPONENT32;
             format = GL_DEPTH_COMPONENT32;
             break;
             break;
+          default:
+            format = GL_DEPTH_COMPONENT;
+            break;
         }
         }
       }
       }
       if (_requested_coverage_samples) {
       if (_requested_coverage_samples) {
@@ -1046,7 +1049,10 @@ bind_slot_multisample(bool rb_resize, Texture **attach, RenderTexturePlane slot,
       case RTP_aux_float_3:
       case RTP_aux_float_3:
         gl_format = GL_RGBA32F_ARB;
         gl_format = GL_RGBA32F_ARB;
         break;
         break;
-    };
+      default:
+        gl_format = GL_RGBA;
+        break;
+    }
 #endif
 #endif
     glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, _rbm[slot]);
     glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, _rbm[slot]);
     if (_requested_coverage_samples) {
     if (_requested_coverage_samples) {

+ 64 - 3
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -2429,9 +2429,17 @@ prepare_display_region(DisplayRegionPipelineReader *dr) {
   set_draw_buffer(_draw_buffer_type);
   set_draw_buffer(_draw_buffer_type);
 
 
   if (dr->get_scissor_enabled()) {
   if (dr->get_scissor_enabled()) {
+    if (GLCAT.is_spam()) {
+      GLCAT.spam()
+        << "glEnable(GL_SCISSOR_TEST)\n";
+    }
     glEnable(GL_SCISSOR_TEST);
     glEnable(GL_SCISSOR_TEST);
     _scissor_enabled = true;
     _scissor_enabled = true;
   } else {
   } else {
+    if (GLCAT.is_spam()) {
+      GLCAT.spam()
+        << "glDisable(GL_SCISSOR_TEST)\n";
+    }
     glDisable(GL_SCISSOR_TEST);
     glDisable(GL_SCISSOR_TEST);
     _scissor_enabled = false;
     _scissor_enabled = false;
   }
   }
@@ -2455,6 +2463,24 @@ prepare_display_region(DisplayRegionPipelineReader *dr) {
     if (dr->get_scissor_enabled()) {
     if (dr->get_scissor_enabled()) {
       _glScissorArrayv(0, count, scissors);
       _glScissorArrayv(0, count, scissors);
     }
     }
+    if (GLCAT.is_spam()) {
+      GLCAT.spam()
+        << "glViewportArrayv(0, " << count << ", [\n";
+      for (int i = 0; i < count; ++i) {
+        GLfloat *vr = viewports + i * 4;
+        GLCAT.spam(false) << vr[0] << ", " << vr[1] << ", " << vr[2] << ", " << vr[3] << ",\n";
+      }
+      GLCAT.spam(false) << "])\n";
+      if (dr->get_scissor_enabled()) {
+        GLCAT.spam()
+          << "glScissorArrayv(0, " << count << ", [\n";
+        for (int i = 0; i < count; ++i) {
+          GLint *sr = scissors + i * 4;
+          GLCAT.spam(false) << sr[0] << ", " << sr[1] << ", " << sr[2] << ", " << sr[3] << ",\n";
+        }
+      }
+      GLCAT.spam(false) << "])\n";
+    }
 
 
   } else
   } else
 #endif  // OPENGLES
 #endif  // OPENGLES
@@ -2463,6 +2489,14 @@ prepare_display_region(DisplayRegionPipelineReader *dr) {
     if (dr->get_scissor_enabled()) {
     if (dr->get_scissor_enabled()) {
       glScissor(x, y, width, height);
       glScissor(x, y, width, height);
     }
     }
+    if (GLCAT.is_spam()) {
+      GLCAT.spam()
+        << "glViewport(" << x << ", " << y << ", " << width << ", " << height << ")\n";
+      if (dr->get_scissor_enabled()) {
+        GLCAT.spam()
+          << "glScissor(" << x << ", " << y << ", " << width << ", " << height << ")\n";
+      }
+    }
   }
   }
 
 
   report_my_gl_errors();
   report_my_gl_errors();
@@ -4892,6 +4926,9 @@ issue_timer_query(int pstats_index) {
   _pending_timer_queries.push_back(DCAST(TimerQueryContext, query));
   _pending_timer_queries.push_back(DCAST(TimerQueryContext, query));
 
 
   return DCAST(TimerQueryContext, query);
   return DCAST(TimerQueryContext, query);
+
+#else
+  return NULL;
 #endif
 #endif
 }
 }
 
 
@@ -6838,6 +6875,10 @@ get_numeric_type(Geom::NumericType numeric_type) {
   case Geom::NT_float64:
   case Geom::NT_float64:
     return GL_DOUBLE;
     return GL_DOUBLE;
 #endif
 #endif
+
+  case Geom::NT_stdfloat:
+    // Shouldn't happen, display error.
+    break;
   }
   }
 
 
   GLCAT.error()
   GLCAT.error()
@@ -7123,6 +7164,7 @@ get_external_image_format(Texture *tex) const {
       case Texture::F_blue:
       case Texture::F_blue:
       case Texture::F_r16:
       case Texture::F_r16:
       case Texture::F_r32:
       case Texture::F_r32:
+      case Texture::F_r32i:
         return GL_COMPRESSED_RED;
         return GL_COMPRESSED_RED;
 
 
       case Texture::F_rg16:
       case Texture::F_rg16:
@@ -7336,7 +7378,11 @@ get_internal_image_format(Texture *tex) const {
       switch (format) {
       switch (format) {
       case Texture::F_color_index:
       case Texture::F_color_index:
       case Texture::F_depth_component:
       case Texture::F_depth_component:
+      case Texture::F_depth_component16:
+      case Texture::F_depth_component24:
+      case Texture::F_depth_component32:
       case Texture::F_depth_stencil:
       case Texture::F_depth_stencil:
+      case Texture::F_r32i:
         // Unsupported; fall through to below.
         // Unsupported; fall through to below.
         break;
         break;
 
 
@@ -7428,8 +7474,6 @@ get_internal_image_format(Texture *tex) const {
           return GL_COMPRESSED_RGBA_FXT1_3DFX;
           return GL_COMPRESSED_RGBA_FXT1_3DFX;
         }
         }
         return GL_COMPRESSED_LUMINANCE_ALPHA;
         return GL_COMPRESSED_LUMINANCE_ALPHA;
-      }
-      break;
 
 
       case Texture::F_srgb:
       case Texture::F_srgb:
         if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
         if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
@@ -7448,6 +7492,8 @@ get_internal_image_format(Texture *tex) const {
 
 
       case Texture::F_sluminance_alpha:
       case Texture::F_sluminance_alpha:
         return GL_COMPRESSED_SLUMINANCE_ALPHA;
         return GL_COMPRESSED_SLUMINANCE_ALPHA;
+      }
+      break;
 #endif
 #endif
 
 
     case Texture::CM_dxt1:
     case Texture::CM_dxt1:
@@ -7802,6 +7848,9 @@ get_texture_apply_mode_type(TextureStage::Mode am) {
   case TextureStage::M_blend_color_scale: return GL_BLEND;
   case TextureStage::M_blend_color_scale: return GL_BLEND;
   case TextureStage::M_modulate_glow: return GL_MODULATE;
   case TextureStage::M_modulate_glow: return GL_MODULATE;
   case TextureStage::M_modulate_gloss: return GL_MODULATE;
   case TextureStage::M_modulate_gloss: return GL_MODULATE;
+  default:
+    // Other modes shouldn't get here.  Fall through and error.
+    break;
   }
   }
 
 
   GLCAT.error()
   GLCAT.error()
@@ -11661,13 +11710,21 @@ void CLP(GraphicsStateGuardian)::
 do_issue_scissor() {
 do_issue_scissor() {
   const ScissorAttrib *target_scissor = DCAST(ScissorAttrib, _target_rs->get_attrib_def(ScissorAttrib::get_class_slot()));
   const ScissorAttrib *target_scissor = DCAST(ScissorAttrib, _target_rs->get_attrib_def(ScissorAttrib::get_class_slot()));
 
 
-  if (target_scissor->is_off()) {
+  if (target_scissor->is_off() && !_current_display_region->get_scissor_enabled()) {
     if (_scissor_enabled) {
     if (_scissor_enabled) {
+      if (GLCAT.is_spam()) {
+        GLCAT.spam()
+          << "glDisable(GL_SCISSOR_TEST)\n";
+      }
       glDisable(GL_SCISSOR_TEST);
       glDisable(GL_SCISSOR_TEST);
       _scissor_enabled = false;
       _scissor_enabled = false;
     }
     }
   } else {
   } else {
     if (!_scissor_enabled) {
     if (!_scissor_enabled) {
+      if (GLCAT.is_spam()) {
+        GLCAT.spam()
+          << "glEnable(GL_SCISSOR_TEST)\n";
+      }
       glEnable(GL_SCISSOR_TEST);
       glEnable(GL_SCISSOR_TEST);
       _scissor_enabled = true;
       _scissor_enabled = true;
     }
     }
@@ -11679,6 +11736,10 @@ do_issue_scissor() {
     int width = (int)(_viewport_width * (frame[1] - frame[0]) + 0.5f);
     int width = (int)(_viewport_width * (frame[1] - frame[0]) + 0.5f);
     int height = (int)(_viewport_height * (frame[3] - frame[2]) + 0.5f);
     int height = (int)(_viewport_height * (frame[3] - frame[2]) + 0.5f);
 
 
+    if (GLCAT.is_spam()) {
+      GLCAT.spam()
+        << "glScissor(" << x << ", " << y << ", " << width << ", " << height << ")\n";
+    }
     glScissor(x, y, width, height);
     glScissor(x, y, width, height);
   }
   }
 }
 }

+ 3 - 0
panda/src/glstuff/glShaderContext_src.cxx

@@ -928,6 +928,7 @@ issue_parameters(int altered) {
         }
         }
       case Shader::SPT_double:
       case Shader::SPT_double:
         GLCAT.error() << "Passing double-precision shader inputs to GLSL shaders is not currently supported\n";
         GLCAT.error() << "Passing double-precision shader inputs to GLSL shaders is not currently supported\n";
+      default:
         continue;
         continue;
       }
       }
     }
     }
@@ -1441,6 +1442,8 @@ glsl_compile_shader(Shader::ShaderType type) {
       }
       }
       break;
       break;
 #endif
 #endif
+    default:
+      break;
   }
   }
   if (!handle) {
   if (!handle) {
     GLCAT.error()
     GLCAT.error()

+ 1 - 1
panda/src/glstuff/glTextureContext_src.h

@@ -37,7 +37,7 @@ public:
   GLuint64 get_handle();
   GLuint64 get_handle();
 
 
 #ifdef OPENGLES
 #ifdef OPENGLES
-  CONSTEXPR bool needs_barrier(GLbitfield barrier) { return false; };
+  static CONSTEXPR bool needs_barrier(GLbitfield barrier) { return false; };
 #else
 #else
   bool needs_barrier(GLbitfield barrier);
   bool needs_barrier(GLbitfield barrier);
   void mark_incoherent(bool wrote);
   void mark_incoherent(bool wrote);

+ 2 - 2
panda/src/grutil/geoMipTerrain.cxx

@@ -273,10 +273,10 @@ generate_block(unsigned short mx,
 double GeoMipTerrain::
 double GeoMipTerrain::
 get_elevation(double x, double y) {
 get_elevation(double x, double y) {
   y = (_ysize - 1) - y;
   y = (_ysize - 1) - y;
+  if (x < 0.0) x = 0.0;
+  if (y < 0.0) y = 0.0;
   unsigned int xlo = (unsigned int) x;
   unsigned int xlo = (unsigned int) x;
   unsigned int ylo = (unsigned int) y;
   unsigned int ylo = (unsigned int) y;
-  if (xlo < 0) xlo = 0;
-  if (ylo < 0) ylo = 0;
   if (xlo > _xsize - 2)
   if (xlo > _xsize - 2)
     xlo = _xsize - 2;
     xlo = _xsize - 2;
   if (ylo > _ysize - 2)
   if (ylo > _ysize - 2)

+ 2 - 2
panda/src/grutil/rigidBodyCombiner.cxx

@@ -193,8 +193,8 @@ r_collect(PandaNode *node, const RenderState *state,
   CPT(RenderState) next_state = state->compose(node->get_state());
   CPT(RenderState) next_state = state->compose(node->get_state());
   CPT(VertexTransform) next_transform = transform;
   CPT(VertexTransform) next_transform = transform;
   if (!node->get_transform()->is_identity() ||
   if (!node->get_transform()->is_identity() ||
-      node->is_of_type(ModelNode::get_class_type()) &&
-      DCAST(ModelNode, node)->get_preserve_transform() != ModelNode::PT_none) {
+      (node->is_of_type(ModelNode::get_class_type()) &&
+       DCAST(ModelNode, node)->get_preserve_transform() != ModelNode::PT_none)) {
     // This node has a transform we need to keep.
     // This node has a transform we need to keep.
     PT(NodeVertexTransform) new_transform = new NodeVertexTransform(node, transform);
     PT(NodeVertexTransform) new_transform = new NodeVertexTransform(node, transform);
     _internal_transforms.push_back(new_transform);
     _internal_transforms.push_back(new_transform);

+ 10 - 6
panda/src/mathutil/triangulator.cxx

@@ -854,17 +854,21 @@ merge_trapezoids(int segnum, int tfirst, int tlast, int side) {
 
 
               /* Change the upper neighbours of the lower trapezoids */
               /* Change the upper neighbours of the lower trapezoids */
 
 
-              if ((tr[t].d0 = tr[tnext].d0) > 0)
-                if (tr[tr[t].d0].u0 == tnext)
+              if ((tr[t].d0 = tr[tnext].d0) > 0) {
+                if (tr[tr[t].d0].u0 == tnext) {
                   tr[tr[t].d0].u0 = t;
                   tr[tr[t].d0].u0 = t;
-                else if (tr[tr[t].d0].u1 == tnext)
+                } else if (tr[tr[t].d0].u1 == tnext) {
                   tr[tr[t].d0].u1 = t;
                   tr[tr[t].d0].u1 = t;
+                }
+              }
 
 
-              if ((tr[t].d1 = tr[tnext].d1) > 0)
-                if (tr[tr[t].d1].u0 == tnext)
+              if ((tr[t].d1 = tr[tnext].d1) > 0) {
+                if (tr[tr[t].d1].u0 == tnext) {
                   tr[tr[t].d1].u0 = t;
                   tr[tr[t].d1].u0 = t;
-                else if (tr[tr[t].d1].u1 == tnext)
+                } else if (tr[tr[t].d1].u1 == tnext) {
                   tr[tr[t].d1].u1 = t;
                   tr[tr[t].d1].u1 = t;
+                }
+              }
 
 
               tr[t].lo = tr[tnext].lo;
               tr[t].lo = tr[tnext].lo;
               tr[tnext].state = ST_INVALID; /* invalidate the lower */
               tr[tnext].state = ST_INVALID; /* invalidate the lower */

+ 17 - 9
panda/src/nativenet/buffered_datagramconnection.h

@@ -34,21 +34,28 @@ private:
   struct AddressQueue : private pvector<Socket_Address> // this is used to do a round robin for addres to connect to ..
   struct AddressQueue : private pvector<Socket_Address> // this is used to do a round robin for addres to connect to ..
   {   
   {   
     size_t _active_index;   
     size_t _active_index;   
-    bool GetNext(Socket_Address &out) 
-    {
+
+    INLINE AddressQueue() : _active_index(0) {}
+
+    bool GetNext(Socket_Address &out) {
       size_t the_size = size();
       size_t the_size = size();
-      if(the_size == 0)
+      if (the_size == 0) {
         return false;
         return false;
-      
-      if(_active_index >= the_size || _active_index < 0)
+      }
+
+      if (_active_index >= the_size) {
         _active_index = 0;
         _active_index = 0;
+      }
+
       out = (*this)[_active_index++];   
       out = (*this)[_active_index++];   
       return true;
       return true;
     }            
     }            
 
 
-    void clear() { pvector<Socket_Address>::clear(); };
-    void push_back(Socket_Address &address)
-    {
+    INLINE void clear() {
+      pvector<Socket_Address>::clear();
+    }
+
+    void push_back(Socket_Address &address) {
       iterator ii;
       iterator ii;
       for(ii = begin(); ii != end(); ii++)
       for(ii = begin(); ii != end(); ii++)
         if(*ii == address)
         if(*ii == address)
@@ -58,8 +65,9 @@ private:
 
 
     size_t size() { return pvector<Socket_Address>::size(); };
     size_t size() { return pvector<Socket_Address>::size(); };
   };
   };
+
 protected:
 protected:
-  // c++ upcals for 
+  // c++ upcalls for 
   virtual void PostConnect(void) { };
   virtual void PostConnect(void) { };
   virtual void NewWriteBuffer(void) { };
   virtual void NewWriteBuffer(void) { };
   ///////////////////////////////////////////
   ///////////////////////////////////////////

+ 7 - 4
panda/src/pgraph/loader.cxx

@@ -396,12 +396,13 @@ save_file(const Filename &filename, const LoaderOptions &options,
         << "Cannot save " << this_filename
         << "Cannot save " << this_filename
         << " without filename extension.\n";
         << " without filename extension.\n";
     }
     }
-    return NULL;
+    return false;
   }
   }
 
 
   LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_global_ptr();
   LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_global_ptr();
   LoaderFileType *requested_type =
   LoaderFileType *requested_type =
     reg->get_type_from_extension(extension);
     reg->get_type_from_extension(extension);
+
   if (requested_type == (LoaderFileType *)NULL) {
   if (requested_type == (LoaderFileType *)NULL) {
     if (report_errors) {
     if (report_errors) {
       loader_cat.error()
       loader_cat.error()
@@ -411,21 +412,23 @@ save_file(const Filename &filename, const LoaderOptions &options,
         << "Currently known scene file types are:\n";
         << "Currently known scene file types are:\n";
       reg->write(loader_cat.error(false), 2);
       reg->write(loader_cat.error(false), 2);
     }
     }
-    return NULL;
+    return false;
+
   } else if (!requested_type->supports_save()) {
   } else if (!requested_type->supports_save()) {
     if (report_errors) {
     if (report_errors) {
       loader_cat.error()
       loader_cat.error()
         << requested_type->get_name() << " file type (."
         << requested_type->get_name() << " file type (."
         << extension << ") does not support saving.\n";
         << extension << ") does not support saving.\n";
     }
     }
-    return NULL;
+    return false;
+
   } else if (pz_file && !requested_type->supports_compressed()) {
   } else if (pz_file && !requested_type->supports_compressed()) {
     if (report_errors) {
     if (report_errors) {
       loader_cat.error()
       loader_cat.error()
         << requested_type->get_name() << " file type (."
         << requested_type->get_name() << " file type (."
         << extension << ") does not support in-line compression.\n";
         << extension << ") does not support in-line compression.\n";
     }
     }
-    return NULL;
+    return false;
   }
   }
 
 
   VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
   VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();

+ 1 - 1
panda/src/pgraph/loaderFileType.cxx

@@ -138,5 +138,5 @@ save_file(const Filename &path, const LoaderOptions &options,
           PandaNode *node) const {
           PandaNode *node) const {
   loader_cat.error()
   loader_cat.error()
     << get_type() << " cannot save PandaNode objects.\n";
     << get_type() << " cannot save PandaNode objects.\n";
-  return NULL;
+  return false;
 }
 }

+ 1 - 1
panda/src/pgraph/modelSaveRequest.I

@@ -77,6 +77,6 @@ is_ready() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE bool ModelSaveRequest::
 INLINE bool ModelSaveRequest::
 get_success() const {
 get_success() const {
-  nassertr(_is_ready, NULL);
+  nassertr(_is_ready, false);
   return _success;
   return _success;
 }
 }

+ 3 - 0
panda/src/pnmimage/pfmFile.cxx

@@ -1811,6 +1811,9 @@ compute_planar_bounds(const LPoint2f &center, PN_float32 point_dist, PN_float32
        LPoint3(max_x, min_y, min_z), LPoint3(min_x, min_y, min_z),
        LPoint3(max_x, min_y, min_z), LPoint3(min_x, min_y, min_z),
        LPoint3(max_x, min_y, max_z), LPoint3(min_x, min_y, max_z));
        LPoint3(max_x, min_y, max_z), LPoint3(min_x, min_y, max_z));
     break;
     break;
+
+  default:
+    nassertr(false, NULL);
   }
   }
 
 
   // Rotate the bounding volume back into the original space of the
   // Rotate the bounding volume back into the original space of the

+ 4 - 4
panda/src/pnmimagetypes/pnmFileTypePNM.cxx

@@ -556,7 +556,7 @@ pgm_writepgminit(ostream * const fileP,
 
 
   (*fileP) 
   (*fileP) 
     << (char)PGM_MAGIC1
     << (char)PGM_MAGIC1
-    << (char)(plainFormat || maxval >= 1<<16 ? PGM_MAGIC2 : RPGM_MAGIC2)
+    << (char)(plainFormat /*|| maxval >= 1<<16*/ ? PGM_MAGIC2 : RPGM_MAGIC2)
     << '\n'
     << '\n'
     << cols << ' ' << rows << '\n' << maxval << '\n';
     << cols << ' ' << rows << '\n' << maxval << '\n';
 }
 }
@@ -577,7 +577,7 @@ ppm_writeppminit(ostream*  const fileP,
 
 
   (*fileP) 
   (*fileP) 
     << (char)PPM_MAGIC1
     << (char)PPM_MAGIC1
-    << (char)(plainFormat || maxval >= 1<<16 ? PPM_MAGIC2 : RPPM_MAGIC2)
+    << (char)(plainFormat /*|| maxval >= 1<<16*/ ? PPM_MAGIC2 : RPPM_MAGIC2)
     << '\n'
     << '\n'
     << cols << ' ' << rows << '\n' << maxval << '\n';
     << cols << ' ' << rows << '\n' << maxval << '\n';
 }
 }
@@ -806,7 +806,7 @@ pgm_writepgmrow(ostream* const fileP,
                 gray  const maxval, 
                 gray  const maxval, 
                 int   const forceplain) {
                 int   const forceplain) {
 
 
-  if (forceplain || pm_plain_output || maxval >= 1<<16)
+  if (forceplain || pm_plain_output /*|| maxval >= 1<<16*/)
     pgm_writepgmrowplain(fileP, grayrow, cols, maxval);
     pgm_writepgmrowplain(fileP, grayrow, cols, maxval);
   else
   else
     pgm_writepgmrowraw(fileP, grayrow, cols, maxval);
     pgm_writepgmrowraw(fileP, grayrow, cols, maxval);
@@ -893,7 +893,7 @@ ppm_writeppmrow(ostream *  const fileP,
                 pixval  const maxval, 
                 pixval  const maxval, 
                 int     const forceplain) {
                 int     const forceplain) {
 
 
-  if (forceplain || pm_plain_output || maxval >= 1<<16) 
+  if (forceplain || pm_plain_output /*|| maxval >= 1<<16*/)
     ppm_writeppmrowplain(fileP, pixelrow, cols, maxval);
     ppm_writeppmrowplain(fileP, pixelrow, cols, maxval);
   else 
   else 
     ppm_writeppmrowraw(fileP, pixelrow, cols, maxval);
     ppm_writeppmrowraw(fileP, pixelrow, cols, maxval);

+ 20 - 3
panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx

@@ -1042,7 +1042,9 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) {
       break;
       break;
 
 
     default:
     default:
-      break;
+      tinydisplay_cat.error()
+        << "Invalid index type " << reader->get_index_type() << "!\n";
+      return false;
     }
     }
 
 
   } else {
   } else {
@@ -1161,6 +1163,11 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) {
           }
           }
         }
         }
         break;
         break;
+
+      default:
+        tinydisplay_cat.error()
+          << "Invalid index type " << reader->get_index_type() << "!\n";
+        return false;
       }
       }
 
 
       start = ends[i] + 2;
       start = ends[i] + 2;
@@ -1258,7 +1265,9 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) {
       break;
       break;
 
 
     default:
     default:
-      break;
+      tinydisplay_cat.error()
+        << "Invalid index type " << reader->get_index_type() << "!\n";
+      return false;
     }
     }
 
 
   } else {
   } else {
@@ -1332,7 +1341,9 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) {
       break;
       break;
 
 
     default:
     default:
-      break;
+      tinydisplay_cat.error()
+        << "Invalid index type " << reader->get_index_type() << "!\n";
+      return false;
     }
     }
 
 
   } else {
   } else {
@@ -2591,6 +2602,12 @@ upload_texture(TinyTextureContext *gtc, bool force) {
     case Texture::F_luminance_alpha:
     case Texture::F_luminance_alpha:
       copy_la_image(dest, xsize, ysize, gtc, level);
       copy_la_image(dest, xsize, ysize, gtc, level);
       break;
       break;
+
+    default:
+      tinydisplay_cat.error()
+        << "Unsupported texture format "
+        << tex->get_format() << "!\n";
+      return false;
     }
     }
 
 
     bytecount += xsize * ysize * 4;
     bytecount += xsize * ysize * 4;

+ 2 - 1
pandatool/src/maya/maya_funcs.cxx

@@ -676,7 +676,8 @@ string_mfndata_type(MFnData::Type type) {
     return "kSubdSurface";
     return "kSubdSurface";
 
 
   case MFnData::kLast:
   case MFnData::kLast:
-    return "kLast";
+  default:
+    break;
   }
   }
 
 
   return "**invalid**";
   return "**invalid**";

+ 4 - 4
pandatool/src/mayaegg/mayaEggLoader.cxx

@@ -175,7 +175,7 @@ MStatus create_enum_attribute(MObject &node, MString fullName, MString briefName
                                    0, &stat );
                                    0, &stat );
   if ( MS::kSuccess != stat ) {
   if ( MS::kSuccess != stat ) {
     mayaloader_cat.error()
     mayaloader_cat.error()
-      << "Could not create new enum attribute " << fullName << "\n";
+      << "Could not create new enum attribute " << fullName.asChar() << "\n";
     return stat;
     return stat;
   }
   }
   for (unsigned i = 0; i < fieldNames.length(); i++){
   for (unsigned i = 0; i < fieldNames.length(); i++){
@@ -185,7 +185,7 @@ MStatus create_enum_attribute(MObject &node, MString fullName, MString briefName
   stat = fnAttr.setDefault(fieldIndex);
   stat = fnAttr.setDefault(fieldIndex);
   if ( MS::kSuccess != stat ) {
   if ( MS::kSuccess != stat ) {
     mayaloader_cat.error()
     mayaloader_cat.error()
-      << "Could not set value for enum attribute " << fullName << "\n";
+      << "Could not set value for enum attribute " << fullName.asChar() << "\n";
     return stat;
     return stat;
   }
   }
 
 
@@ -195,10 +195,10 @@ MStatus create_enum_attribute(MObject &node, MString fullName, MString briefName
   fnAttr.setStorable( true ); 
   fnAttr.setStorable( true ); 
 
 
   // Now add the new attribute to this dependency node
   // Now add the new attribute to this dependency node
-  stat = fnDN.addAttribute(newAttr,MFnDependencyNode::kLocalDynamicAttr);
+  stat = fnDN.addAttribute(newAttr, MFnDependencyNode::kLocalDynamicAttr);
   if ( MS::kSuccess != stat ) {
   if ( MS::kSuccess != stat ) {
     mayaloader_cat.error()
     mayaloader_cat.error()
-      << "Could not add new enum attribute " << fullName << "\n";
+      << "Could not add new enum attribute " << fullName.asChar() << "\n";
     return stat;
     return stat;
   }
   }
 
 

+ 108 - 18
pandatool/src/mayaegg/mayaToEggConverter.cxx

@@ -101,6 +101,7 @@ MayaToEggConverter(const string &program_name) :
   _round_uvs = false;
   _round_uvs = false;
   _legacy_shader = false;
   _legacy_shader = false;
   _convert_cameras = false;
   _convert_cameras = false;
+  _convert_lights = false;
 
 
   _transform_type = TT_model;
   _transform_type = TT_model;
 }
 }
@@ -127,6 +128,7 @@ MayaToEggConverter(const MayaToEggConverter &copy) :
   _always_show_vertex_color(copy._always_show_vertex_color),
   _always_show_vertex_color(copy._always_show_vertex_color),
   _keep_all_uvsets(copy._keep_all_uvsets),
   _keep_all_uvsets(copy._keep_all_uvsets),
   _convert_cameras(copy._convert_cameras),
   _convert_cameras(copy._convert_cameras),
+  _convert_lights(copy._convert_lights),
   _round_uvs(copy._round_uvs),
   _round_uvs(copy._round_uvs),
   _legacy_shader(copy._legacy_shader),
   _legacy_shader(copy._legacy_shader),
   _transform_type(copy._transform_type)
   _transform_type(copy._transform_type)
@@ -837,6 +839,9 @@ convert_hierarchy(EggGroupNode *egg_root) {
   if (_convert_cameras) {
   if (_convert_cameras) {
     mayaegg_cat.info() << "will convert camera nodes to locators" << endl;
     mayaegg_cat.info() << "will convert camera nodes to locators" << endl;
   }
   }
+  if (_convert_lights) {
+    mayaegg_cat.info() << "will convert light nodes to locators" << endl;
+  }
   // give some feedback about whether special options are on
   // give some feedback about whether special options are on
   if (_legacy_shader) {
   if (_legacy_shader) {
     mayaegg_cat.info() << "will disable modern Phong shader path. using legacy" << endl;
     mayaegg_cat.info() << "will disable modern Phong shader path. using legacy" << endl;
@@ -964,11 +969,40 @@ process_model_node(MayaNodeDesc *node_desc) {
     }
     }
 
 
   } else if (dag_path.hasFn(MFn::kLight)) {
   } else if (dag_path.hasFn(MFn::kLight)) {
-    if (mayaegg_cat.is_debug()) {
-      mayaegg_cat.debug()
-        << "Ignoring light node " << path
-        << "\n";
-    }
+    if (_convert_lights) {
+      MFnLight light (dag_path, &status);
+      if ( !status ) {
+        status.perror("MFnLight constructor");
+        return false;
+      }
+
+      EggGroup *egg_group = _tree.get_egg_group(node_desc);
+
+      if (mayaegg_cat.is_debug()) {
+        mayaegg_cat.warning() << "Saving light node as a locator: " << path << endl;
+      }
+
+      if (node_desc->is_tagged()) {
+        // Presumably, the lighht's position has some meaning to the
+        // end-user, so we will implicitly tag it with the DCS flag so it
+        // won't get flattened out.
+        if (_animation_convert != AC_model) {
+          // For now, don't set the DCS flag on lights within
+          // character models, since egg-optchar doesn't understand
+          // this.  Perhaps there's no reason to ever change this, since
+          // lights within character models may not be meaningful.
+          egg_group->set_dcs_type(EggGroup::DC_net);
+        }
+        get_transform(node_desc, dag_path, egg_group);
+        make_light_locator(dag_path, dag_node, egg_group);
+      } else {
+        if (mayaegg_cat.is_debug()) {
+          mayaegg_cat.debug()
+            << "Ignoring light node " << path
+            << "\n";
+          }
+        }
+      }
  
  
     MFnLight light (dag_path, &status);
     MFnLight light (dag_path, &status);
     if ( !status ) {
     if ( !status ) {
@@ -976,9 +1010,9 @@ process_model_node(MayaNodeDesc *node_desc) {
       mayaegg_cat.error() << "light extraction failed" << endl;
       mayaegg_cat.error() << "light extraction failed" << endl;
       return false;
       return false;
     }
     }
-    mayaegg_cat.debug() << "-- Light found -- tranlations in cm, rotations in rads\n";
+    mayaegg_cat.info() << "-- Light found -- tranlations in cm, rotations in rads\n";
 
 
-    mayaegg_cat.debug() << "\"" << dag_path.partialPathName() << "\" : \n";
+    mayaegg_cat.info() << "\"" << dag_path.partialPathName() << "\" : \n";
 
 
     // Get the translation/rotation/scale data
     // Get the translation/rotation/scale data
     MObject transformNode = dag_path.transform(&status);
     MObject transformNode = dag_path.transform(&status);
@@ -1003,18 +1037,18 @@ process_model_node(MayaNodeDesc *node_desc) {
       tl.z = 0;
       tl.z = 0;
     }
     }
     // We swap Y and Z in the next few bits cuz Panda is Z-up by default and Maya is Y-up
     // We swap Y and Z in the next few bits cuz Panda is Z-up by default and Maya is Y-up
-    mayaegg_cat.debug() << "  \"translation\" : (" << tl.x << ", " << tl.z << ", " << tl.y << ")"
+    mayaegg_cat.info() << "  \"translation\" : (" << tl.x << ", " << tl.z << ", " << tl.y << ")"
          << endl;
          << endl;
     double threeDoubles[3];
     double threeDoubles[3];
     MTransformationMatrix::RotationOrder	rOrder;
     MTransformationMatrix::RotationOrder	rOrder;
     
     
     matrix.getRotation (threeDoubles, rOrder, MSpace::kWorld);
     matrix.getRotation (threeDoubles, rOrder, MSpace::kWorld);
-    mayaegg_cat.debug() << "  \"rotation\": ("
+    mayaegg_cat.info() << "  \"rotation\": ("
          << threeDoubles[0] << ", "
          << threeDoubles[0] << ", "
          << threeDoubles[2] << ", "
          << threeDoubles[2] << ", "
          << threeDoubles[1] << ")\n";
          << threeDoubles[1] << ")\n";
     matrix.getScale (threeDoubles, MSpace::kWorld);
     matrix.getScale (threeDoubles, MSpace::kWorld);
-    mayaegg_cat.debug() << "  \"scale\" : ("
+    mayaegg_cat.info() << "  \"scale\" : ("
          << threeDoubles[0] << ", "
          << threeDoubles[0] << ", "
          << threeDoubles[2] << ", "
          << threeDoubles[2] << ", "
          << threeDoubles[1] << ")\n";
          << threeDoubles[1] << ")\n";
@@ -1022,12 +1056,12 @@ process_model_node(MayaNodeDesc *node_desc) {
     // Extract some interesting Light data
     // Extract some interesting Light data
     MColor color;
     MColor color;
     color = light.color();
     color = light.color();
-    mayaegg_cat.debug() << "  \"color\" : ("
+    mayaegg_cat.info() << "  \"color\" : ("
          << color.r << ", "
          << color.r << ", "
          << color.g << ", "
          << color.g << ", "
          << color.b << ")\n";
          << color.b << ")\n";
     color = light.shadowColor();
     color = light.shadowColor();
-    mayaegg_cat.debug() << "  \"intensity\" : " << light.intensity() << endl;
+    mayaegg_cat.info() << "  \"intensity\" : " << light.intensity() << endl;
 
 
   } else if (dag_path.hasFn(MFn::kNurbsSurface)) {
   } else if (dag_path.hasFn(MFn::kNurbsSurface)) {
     EggGroup *egg_group = _tree.get_egg_group(node_desc);
     EggGroup *egg_group = _tree.get_egg_group(node_desc);
@@ -2322,7 +2356,7 @@ make_locator(const MDagPath &dag_path, const MFnDagNode &dag_node,
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: MayaToEggConverter::make_locator
+//     Function: MayaToEggConverter::make_camera_locator
 //       Access: Private
 //       Access: Private
 //  Description: Locators are used in Maya to indicate a particular
 //  Description: Locators are used in Maya to indicate a particular
 //               position in space to the user or the modeler.  We
 //               position in space to the user or the modeler.  We
@@ -2365,6 +2399,62 @@ make_camera_locator(const MDagPath &dag_path, const MFnDagNode &dag_node,
 }
 }
 
 
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: MayaToEggConverter::make_light_locator
+//       Access: Private
+//  Description: Locators are used in Maya to indicate a particular
+//               position in space to the user or the modeler.  We
+//               represent that in egg with an ordinary Group node,
+//               which we transform by the locator's position, so that
+//               the indicated point becomes the origin at this node
+//               and below.
+////////////////////////////////////////////////////////////////////
+void MayaToEggConverter::
+make_light_locator(const MDagPath &dag_path, const MFnDagNode &dag_node,
+             EggGroup *egg_group) {
+  MStatus status;
+
+  unsigned int num_children = dag_node.childCount();
+  MObject locator;
+  bool found_alight = false;
+  bool found_dlight = false;
+  bool found_plight = false;
+  for (unsigned int ci = 0; ci < num_children && !found_alight && !found_dlight && !found_plight; ci++) {
+    locator = dag_node.child(ci);
+    found_alight = (locator.apiType() == MFn::kAmbientLight);
+    found_dlight = (locator.apiType() == MFn::kDirectionalLight);
+    found_plight = (locator.apiType() == MFn::kPointLight);
+  }
+
+  if (!found_alight && !found_dlight && !found_plight) {
+    mayaegg_cat.error()
+      << "Couldn't find light within locator node " 
+      << dag_path.fullPathName().asChar() << "\n";
+    return;
+  }
+
+  LPoint3d p3d;
+
+  // We need to convert the position to world coordinates.  For some
+  // reason, Maya can only tell it to us in local coordinates.
+  MMatrix mat = dag_path.inclusiveMatrix(&status);
+  if (!status) {
+    status.perror("Can't get coordinate space for light");
+    return;
+  }
+  LMatrix4d n2w(mat[0][0], mat[0][1], mat[0][2], mat[0][3],
+                mat[1][0], mat[1][1], mat[1][2], mat[1][3],
+                mat[2][0], mat[2][1], mat[2][2], mat[2][3],
+                mat[3][0], mat[3][1], mat[3][2], mat[3][3]);
+  p3d = p3d * n2w;
+
+  // Now convert the locator point into the group's space.
+  p3d = p3d * egg_group->get_node_frame_inv();
+
+  egg_group->add_translate3d(p3d);
+}
+
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: MayaToEggConverter::get_vertex_weights
 //     Function: MayaToEggConverter::get_vertex_weights
 //       Access: Private
 //       Access: Private
@@ -2722,14 +2812,14 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader,
     }
     }
     if (color_def->_has_texture || trans_def._has_texture) {
     if (color_def->_has_texture || trans_def._has_texture) {
       EggTexture tex(shader.get_name(), "");
       EggTexture tex(shader.get_name(), "");
-      if (mayaegg_cat.is_debug()) {
-        mayaegg_cat.debug() << "got shader name:" << shader.get_name() << endl;
-        mayaegg_cat.debug() << "ssa:texture name[" << i << "]: " << color_def->_texture_name << endl;
+      if (mayaegg_cat.is_spam()) {
+        mayaegg_cat.spam() << "got shader name:" << shader.get_name() << endl;
+        mayaegg_cat.spam() << "ssa:texture name[" << i << "]: " << color_def->_texture_name << endl;
       }
       }
 
 
       string uvset_name = _shaders.find_uv_link(color_def->_texture_name);
       string uvset_name = _shaders.find_uv_link(color_def->_texture_name);
-      if (mayaegg_cat.is_debug()) {
-        mayaegg_cat.debug() << "ssa:corresponding uvset name is " << uvset_name << endl;
+      if (mayaegg_cat.is_spam()) {
+        mayaegg_cat.spam() << "ssa:corresponding uvset name is " << uvset_name << endl;
       }
       }
 
 
       if (color_def->_has_texture) {
       if (color_def->_has_texture) {

+ 3 - 0
pandatool/src/mayaegg/mayaToEggConverter.h

@@ -141,6 +141,8 @@ private:
                     EggGroup *egg_group);
                     EggGroup *egg_group);
   void make_camera_locator(const MDagPath &dag_path, const MFnDagNode &dag_node,
   void make_camera_locator(const MDagPath &dag_path, const MFnDagNode &dag_node,
                     EggGroup *egg_group);
                     EggGroup *egg_group);
+  void make_light_locator(const MDagPath &dag_path, const MFnDagNode &dag_node,
+                    EggGroup *egg_group);
   bool get_vertex_weights(const MDagPath &dag_path, const MFnMesh &mesh,
   bool get_vertex_weights(const MDagPath &dag_path, const MFnMesh &mesh,
                           pvector<EggGroup *> &joints, MFloatArray &weights);
                           pvector<EggGroup *> &joints, MFloatArray &weights);
   bool get_vertex_weights(const MDagPath &dag_path, const MFnNurbsSurface &surface,
   bool get_vertex_weights(const MDagPath &dag_path, const MFnNurbsSurface &surface,
@@ -194,6 +196,7 @@ public:
   bool _always_show_vertex_color;
   bool _always_show_vertex_color;
   bool _keep_all_uvsets;
   bool _keep_all_uvsets;
   bool _convert_cameras;
   bool _convert_cameras;
+  bool _convert_lights;
   bool _round_uvs;
   bool _round_uvs;
   bool _legacy_shader;
   bool _legacy_shader;
 
 

+ 6 - 0
pandatool/src/mayaprogs/mayaToEgg.cxx

@@ -107,6 +107,11 @@ MayaToEgg() :
      "Convert all camera nodes to locators. Will preserve position and rotation.",
      "Convert all camera nodes to locators. Will preserve position and rotation.",
      &MayaToEgg::dispatch_none, &_convert_cameras);
      &MayaToEgg::dispatch_none, &_convert_cameras);
 
 
+  add_option
+    ("convert-lights", "", 0,
+     "Convert all light nodes to locators. Will preserve position and rotation only.",
+     &MayaToEgg::dispatch_none, &_convert_lights);
+
   add_option
   add_option
     ("keep-uvs", "", 0,
     ("keep-uvs", "", 0,
      "Convert all UV sets on all vertices, even those that do not appear "
      "Convert all UV sets on all vertices, even those that do not appear "
@@ -248,6 +253,7 @@ run() {
   converter._always_show_vertex_color = !_suppress_vertex_color;
   converter._always_show_vertex_color = !_suppress_vertex_color;
   converter._keep_all_uvsets = _keep_all_uvsets;
   converter._keep_all_uvsets = _keep_all_uvsets;
   converter._convert_cameras = _convert_cameras;
   converter._convert_cameras = _convert_cameras;
+  converter._convert_lights = _convert_lights;
   converter._round_uvs = _round_uvs;
   converter._round_uvs = _round_uvs;
   converter._transform_type = _transform_type;
   converter._transform_type = _transform_type;
   converter._legacy_shader = _legacy_shader;
   converter._legacy_shader = _legacy_shader;

+ 1 - 0
pandatool/src/mayaprogs/mayaToEgg.h

@@ -39,6 +39,7 @@ protected:
   bool _suppress_vertex_color;
   bool _suppress_vertex_color;
   bool _keep_all_uvsets;
   bool _keep_all_uvsets;
   bool _convert_cameras;
   bool _convert_cameras;
+  bool _convert_lights;
   bool _round_uvs;
   bool _round_uvs;
   bool _legacy_shader;
   bool _legacy_shader;
   bool _legacy_copytex;
   bool _legacy_copytex;