Browse Source

introduce model-cache-dir

David Rose 19 years ago
parent
commit
86837677b6
2 changed files with 27 additions and 2 deletions
  1. 12 0
      pandatool/src/bam/bamInfo.cxx
  2. 15 2
      pandatool/src/bam/bamToEgg.cxx

+ 12 - 0
pandatool/src/bam/bamInfo.cxx

@@ -27,6 +27,7 @@
 #include "recorderTable.h"
 #include "dcast.h"
 #include "pvector.h"
+#include "bamCacheRecord.h"
 
 ////////////////////////////////////////////////////////////////////
 //     Function: BamInfo::Constructor
@@ -131,6 +132,17 @@ get_info(const Filename &filename) {
 
   Objects objects;
   TypedWritable *object = bam_file.read_object();
+
+  if (object != (TypedWritable *)NULL && 
+      object->is_exact_type(BamCacheRecord::get_class_type())) {
+    // Here's a special case: if the first object in the file is a
+    // BamCacheRecord, it's a cache data file; in this case, we output
+    // the cache record, and then pretend it doesn't exist.
+    DCAST(BamCacheRecord, object)->write(nout, 2);
+    nout << "\n";
+    object = bam_file.read_object();
+  }
+
   while (object != (TypedWritable *)NULL || !bam_file.is_eof()) {
     if (object != (TypedWritable *)NULL) {
       objects.push_back(object);

+ 15 - 2
pandatool/src/bam/bamToEgg.cxx

@@ -35,6 +35,7 @@
 #include "geomVertexReader.h"
 #include "string_utils.h"
 #include "bamFile.h"
+#include "bamCacheRecord.h"
 #include "eggGroup.h"
 #include "eggVertexPool.h"
 #include "eggVertex.h"
@@ -93,6 +94,16 @@ run() {
   typedef pvector<TypedWritable *> Objects;
   Objects objects;
   TypedWritable *object = bam_file.read_object();
+
+  if (object != (TypedWritable *)NULL && 
+      object->is_exact_type(BamCacheRecord::get_class_type())) {
+    // Here's a special case: if the first object in the file is a
+    // BamCacheRecord, it's really a cache data file and not a true
+    // bam file; but skip over the cache data record and let the user
+    // treat it like an ordinary bam file.
+    object = bam_file.read_object();
+  }
+
   while (object != (TypedWritable *)NULL || !bam_file.is_eof()) {
     if (object != (TypedWritable *)NULL) {
       objects.push_back(object);
@@ -467,8 +478,6 @@ get_egg_texture(Texture *tex) {
       }
 
       switch (tex->get_minfilter()) {
-      case Texture::FT_invalid:
-        break;
       case Texture::FT_nearest:
         temp.set_minfilter(EggTexture::FT_nearest);
         break;
@@ -487,6 +496,9 @@ get_egg_texture(Texture *tex) {
       case Texture::FT_linear_mipmap_linear:
         temp.set_minfilter(EggTexture::FT_linear_mipmap_linear);
         break;
+
+      default:
+        break;
       }
 
       switch (tex->get_magfilter()) {
@@ -496,6 +508,7 @@ get_egg_texture(Texture *tex) {
       case Texture::FT_linear:
         temp.set_magfilter(EggTexture::FT_linear);
         break;
+
       default:
         break;
       }