Ver Fonte

add BTM_unchanged

David Rose há 23 anos atrás
pai
commit
12e9117087

+ 8 - 6
panda/src/gobj/config_gobj.cxx

@@ -31,8 +31,8 @@
 #include "lens.h"
 #include "texture.h"
 
-#include <dconfig.h>
-#include <string_utils.h>
+#include "dconfig.h"
+#include "string_utils.h"
 
 Configure(config_gobj);
 NotifyCategoryDef(gobj, "");
@@ -125,15 +125,17 @@ const float default_far = config_gobj.GetFloat("default-far", 1000.0f);
 
 static BamTextureMode
 parse_texture_mode(const string &mode) {
-  if (mode == "fullpath") {
+  if (cmp_nocase(mode, "unchanged") == 0) {
+    return BTM_unchanged;
+  } else if (cmp_nocase(mode, "fullpath") == 0) {
     return BTM_fullpath;
-  } else if (mode == "relative") {
+  } else if (cmp_nocase(mode, "relative") == 0) {
     return BTM_relative;
-  } else if (mode == "basename") {
+  } else if (cmp_nocase(mode, "basename") == 0) {
     return BTM_basename;
   }
 
-  gobj_cat.error() << "Invalid bam-texture-mode: " << mode << "\n";
+  gobj_cat->error() << "Invalid bam-texture-mode: " << mode << "\n";
   return BTM_relative;
 }
 

+ 3 - 2
panda/src/gobj/config_gobj.h

@@ -19,8 +19,8 @@
 #ifndef CONFIG_GOBJ_H
 #define CONFIG_GOBJ_H
 
-#include <pandabase.h>
-#include <notifyCategoryProxy.h>
+#include "pandabase.h"
+#include "notifyCategoryProxy.h"
 
 NotifyCategoryDecl(gobj, EXPCL_PANDA, EXPTP_PANDA);
 
@@ -35,6 +35,7 @@ extern EXPCL_PANDA bool keep_geom_ram;
 extern EXPCL_PANDA bool retained_mode;
 
 enum BamTextureMode {
+  BTM_unchanged,
   BTM_fullpath,
   BTM_relative,
   BTM_basename

+ 1 - 0
panda/src/gobj/imageBuffer.cxx

@@ -47,6 +47,7 @@ write_datagram(BamWriter *, Datagram &me)
   Filename alpha_filename = get_alpha_filename();
 
   switch (bam_texture_mode) {
+  case BTM_unchanged:
   case BTM_fullpath:
     break;
 

+ 20 - 3
panda/src/gobj/texturePool.cxx

@@ -32,7 +32,9 @@ TexturePool *TexturePool::_global_ptr = (TexturePool *)NULL;
 //  Description: The nonstatic implementation of has_texture().
 ////////////////////////////////////////////////////////////////////
 bool TexturePool::
-ns_has_texture(Filename filename) {
+ns_has_texture(const Filename &orig_filename) {
+  Filename filename(orig_filename);
+
   if (!fake_texture_image.empty()) {
     filename = fake_texture_image;
   }
@@ -63,7 +65,9 @@ ns_has_texture(Filename filename) {
 //  Description: The nonstatic implementation of load_texture().
 ////////////////////////////////////////////////////////////////////
 Texture *TexturePool::
-ns_load_texture(Filename filename) {
+ns_load_texture(const Filename &orig_filename) {
+  Filename filename(orig_filename);
+
   if (!fake_texture_image.empty()) {
     filename = fake_texture_image;
   }
@@ -94,6 +98,10 @@ ns_load_texture(Filename filename) {
     return NULL;
   }
 
+  if (bam_texture_mode == BTM_unchanged) {
+    tex->set_filename(orig_filename);
+  }
+
   _textures[filename] = tex;
   return tex;
 }
@@ -104,7 +112,11 @@ ns_load_texture(Filename filename) {
 //  Description: The nonstatic implementation of load_texture().
 ////////////////////////////////////////////////////////////////////
 Texture *TexturePool::
-ns_load_texture(Filename filename, Filename grayfilename) {
+ns_load_texture(const Filename &orig_filename, 
+                const Filename &orig_grayfilename) {
+  Filename filename(orig_filename);
+  Filename grayfilename(orig_grayfilename);
+
   if (!fake_texture_image.empty()) {
     return ns_load_texture(fake_texture_image);
   }
@@ -142,6 +154,11 @@ ns_load_texture(Filename filename, Filename grayfilename) {
     return NULL;
   }
 
+  if (bam_texture_mode == BTM_unchanged) {
+    tex->set_filename(orig_filename);
+    tex->set_alpha_filename(orig_grayfilename);
+  }
+
   _textures[filename] = tex;
   return tex;
 }

+ 4 - 3
panda/src/gobj/texturePool.h

@@ -56,9 +56,10 @@ PUBLISHED:
 private:
   INLINE TexturePool();
 
-  bool ns_has_texture(Filename filename);
-  Texture *ns_load_texture(Filename filename);
-  Texture *ns_load_texture(Filename filename, Filename grayfilename);
+  bool ns_has_texture(const Filename &orig_filename);
+  Texture *ns_load_texture(const Filename &orig_filename);
+  Texture *ns_load_texture(const Filename &orig_filename, 
+                           const Filename &orig_grayfilename);
   void ns_add_texture(Texture *texture);
   void ns_release_texture(Texture *texture);
   void ns_release_all_textures();