Browse Source

Merge branch 'release/1.10.x'

rdb 5 years ago
parent
commit
e2177ecbdb

+ 1 - 1
direct/src/controls/ControlManager.py

@@ -144,7 +144,7 @@ class ControlManager:
     def delete(self):
         assert self.notify.debugCall(id(self))
         self.disable()
-        for controls in self.controls.keys():
+        for controls in list(self.controls.keys()):
             self.remove(controls)
         del self.controls
         del self.currentControls

+ 33 - 5
direct/src/dist/commands.py

@@ -571,15 +571,19 @@ class build_apps(setuptools.Command):
             libdir = os.path.dirname(dtool_fn.to_os_specific())
             etcdir = os.path.join(libdir, '..', 'etc')
 
-            for fn in os.listdir(etcdir):
+            etcfiles = os.listdir(etcdir)
+            etcfiles.sort(reverse=True)
+            for fn in etcfiles:
                 if fn.lower().endswith('.prc'):
                     with open(os.path.join(etcdir, fn)) as f:
                         prcstring += f.read()
         else:
             etcfiles = [i for i in p3dwhl.namelist() if i.endswith('.prc')]
+            etcfiles.sort(reverse=True)
             for fn in etcfiles:
                 with p3dwhl.open(fn) as f:
                     prcstring += f.read().decode('utf8')
+
         user_prcstring = self.extra_prc_data
         for fn in self.extra_prc_files:
             with open(fn) as f:
@@ -598,12 +602,33 @@ class build_apps(setuptools.Command):
             for ln in prcstr.split('\n'):
                 ln = ln.strip()
                 useline = True
+
                 if ln.startswith('#') or not ln:
                     continue
-                if 'model-cache-dir' in ln:
-                    ln = ln.replace('/panda3d', '/{}'.format(self.distribution.get_name()))
+
+                words = ln.split(None, 1)
+                if not words:
+                    continue
+                var = words[0]
+                value = words[1] if len(words) > 1 else ''
+
+                # Strip comment after value.
+                c = value.find(' #')
+                if c > 0:
+                    value = value[:c].rstrip()
+
+                if var == 'model-cache-dir' and value:
+                    value = value.replace('/panda3d', '/{}'.format(self.distribution.get_name()))
+
+                if var == 'audio-library-name':
+                    # We have the default set to p3fmod_audio on macOS in 1.10,
+                    # but this can be unexpected as other platforms use OpenAL
+                    # by default.  Switch it up if FMOD is not included.
+                    if value not in self.plugins and value == 'p3fmod_audio' and 'p3openal_audio' in self.plugins:
+                        self.warn("Missing audio plugin p3fmod_audio referenced in PRC data, replacing with p3openal_audio")
+
                 for plugin in check_plugins:
-                    if plugin in ln and plugin not in self.plugins:
+                    if plugin in value and plugin not in self.plugins:
                         useline = False
                         if warn_on_missing_plugin:
                             self.warn(
@@ -611,7 +636,10 @@ class build_apps(setuptools.Command):
                             )
                         break
                 if useline:
-                    out.append(ln)
+                    if value:
+                        out.append(var + ' ' + value)
+                    else:
+                        out.append(var)
             return out
         prcexport = parse_prc(prcstring, 0) + parse_prc(user_prcstring, 1)
 

+ 1 - 1
panda/src/downloader/multiplexStream.I

@@ -37,7 +37,7 @@ add_ostream(std::ostream *out, bool delete_later) {
 INLINE bool MultiplexStream::
 add_stdio_file(FILE *fout, bool close_when_done) {
   _msb.add_output(MultiplexStreamBuf::BT_line,
-                  MultiplexStreamBuf::OT_ostream,
+                  MultiplexStreamBuf::OT_stdio,
                   nullptr, fout, close_when_done);
   return true;
 }

+ 29 - 1
panda/src/pgraph/renderState.I

@@ -481,6 +481,34 @@ flush_level() {
   _cache_counter.flush_level();
 }
 
+/**
+ * Overrides this method to update PStats appropriately.
+ */
+INLINE void RenderState::
+cache_ref_only() const {
+#ifdef DO_PSTATS
+  int old_referenced_bits = get_referenced_bits();
+  NodeCachedReferenceCount::cache_ref_only();
+  consider_update_pstats(old_referenced_bits);
+#else  // DO_PSTATS
+  NodeCachedReferenceCount::cache_ref_only();
+#endif  // DO_PSTATS
+}
+
+/**
+ * Overrides this method to update PStats appropriately.
+ */
+INLINE void RenderState::
+cache_unref_only() const {
+#ifdef DO_PSTATS
+  int old_referenced_bits = get_referenced_bits();
+  NodeCachedReferenceCount::cache_unref_only();
+  consider_update_pstats(old_referenced_bits);
+#else  // DO_PSTATS
+  NodeCachedReferenceCount::cache_unref_only();
+#endif  // DO_PSTATS
+}
+
 #ifndef CPPPARSER
 /**
  * Handy templated version of get_attrib that casts to the right type.
@@ -533,7 +561,7 @@ check_hash() const {
  */
 INLINE bool RenderState::
 do_cache_unref() const {
-  cache_unref_only();
+  NodeCachedReferenceCount::cache_unref_only();
   return unref();
 }
 

+ 5 - 0
panda/src/pgraph/renderState.h

@@ -169,6 +169,11 @@ public:
   INLINE void get_attrib_def(CPT(AttribType) &attrib) const;
 #endif  // CPPPARSER
 
+  INLINE void cache_ref_only() const;
+
+protected:
+  INLINE void cache_unref_only() const;
+
 private:
   INLINE void check_hash() const;
   bool validate_filled_slots() const;

+ 29 - 1
panda/src/pgraph/transformState.I

@@ -753,6 +753,34 @@ flush_level() {
   _cache_counter.flush_level();
 }
 
+/**
+ * Overrides this method to update PStats appropriately.
+ */
+INLINE void TransformState::
+cache_ref_only() const {
+#ifdef DO_PSTATS
+  int old_referenced_bits = get_referenced_bits();
+  NodeCachedReferenceCount::cache_ref_only();
+  consider_update_pstats(old_referenced_bits);
+#else  // DO_PSTATS
+  NodeCachedReferenceCount::cache_ref_only();
+#endif  // DO_PSTATS
+}
+
+/**
+ * Overrides this method to update PStats appropriately.
+ */
+INLINE void TransformState::
+cache_unref_only() const {
+#ifdef DO_PSTATS
+  int old_referenced_bits = get_referenced_bits();
+  NodeCachedReferenceCount::cache_unref_only();
+  consider_update_pstats(old_referenced_bits);
+#else  // DO_PSTATS
+  NodeCachedReferenceCount::cache_unref_only();
+#endif  // DO_PSTATS
+}
+
 /**
  * Reimplements NodeReferenceCount::node_unref().  We do this because we have
  * a non-virtual unref() method.
@@ -769,7 +797,7 @@ do_node_unref() const {
  */
 INLINE bool TransformState::
 do_cache_unref() const {
-  cache_unref_only();
+  NodeCachedReferenceCount::cache_unref_only();
   return unref();
 }
 

+ 5 - 0
panda/src/pgraph/transformState.h

@@ -213,6 +213,11 @@ public:
 
   INLINE static void flush_level();
 
+  INLINE void cache_ref_only() const;
+
+protected:
+  INLINE void cache_unref_only() const;
+
 private:
   INLINE bool do_cache_unref() const;
   INLINE bool do_node_unref() const;

+ 4 - 4
panda/src/pnmimage/pnmImage.cxx

@@ -1176,7 +1176,7 @@ add_sub_image(const PNMImage &copy, int xto, int yto,
   if (has_alpha() && copy.has_alpha()) {
     for (y = ymin; y < ymax; y++) {
       for (x = xmin; x < xmax; x++) {
-        set_alpha(x, y, get_alpha(x, y) + copy.get_alpha(x, y) * pixel_scale);
+        set_alpha(x, y, get_alpha(x, y) + copy.get_alpha(x - xmin + xfrom, y - ymin + yfrom) * pixel_scale);
       }
     }
   }
@@ -1184,7 +1184,7 @@ add_sub_image(const PNMImage &copy, int xto, int yto,
   for (y = ymin; y < ymax; y++) {
     for (x = xmin; x < xmax; x++) {
       LRGBColorf rgb1 = get_xel(x, y);
-      LRGBColorf rgb2 = copy.get_xel(x, y);
+      LRGBColorf rgb2 = copy.get_xel(x - xmin + xfrom, y - ymin + yfrom);
       set_xel(x, y,
               rgb1[0] + rgb2[0] * pixel_scale,
               rgb1[1] + rgb2[1] * pixel_scale,
@@ -1210,7 +1210,7 @@ mult_sub_image(const PNMImage &copy, int xto, int yto,
   if (has_alpha() && copy.has_alpha()) {
     for (y = ymin; y < ymax; y++) {
       for (x = xmin; x < xmax; x++) {
-        set_alpha(x, y, get_alpha(x, y) * copy.get_alpha(x, y) * pixel_scale);
+        set_alpha(x, y, get_alpha(x, y) * copy.get_alpha(x - xmin + xfrom, y - ymin + yfrom) * pixel_scale);
       }
     }
   }
@@ -1218,7 +1218,7 @@ mult_sub_image(const PNMImage &copy, int xto, int yto,
   for (y = ymin; y < ymax; y++) {
     for (x = xmin; x < xmax; x++) {
       LRGBColorf rgb1 = get_xel(x, y);
-      LRGBColorf rgb2 = copy.get_xel(x, y);
+      LRGBColorf rgb2 = copy.get_xel(x - xmin + xfrom, y - ymin + yfrom);
       set_xel(x, y,
               rgb1[0] * rgb2[0] * pixel_scale,
               rgb1[1] * rgb2[1] * pixel_scale,

+ 37 - 0
tests/pnmimage/test_pnmimage.py

@@ -70,3 +70,40 @@ def test_pnmimage_quantize():
             assert col.b in (0, 1)
 
     assert max_dist < 0.1 ** 2
+
+def test_pnmimage_add_sub_image():
+    dst = PNMImage(2, 2)
+    dst.fill(0.5, 0, 0)   #adding color to dst
+    #dst_color will store rgb values at each pixel of dst
+    dst_color = ((dst.get_xel(0, 0), dst.get_xel(0, 1)), (dst.get_xel(1, 0), dst.get_xel(1, 1)))
+
+    src = PNMImage(1, 1)
+    src.fill(0, 0.7, 0)   #adding color to src
+    #src_color will store rgb values at each pixel of src
+    src_color = src.get_xel(0, 0)
+
+    dst.add_sub_image(src, 1, 1, 0, 0, 1, 1)
+    final_color = ((dst.get_xel(0, 0), dst.get_xel(0, 1)), (dst.get_xel(1, 0), dst.get_xel(1, 1)))
+    assert final_color[0][0] == dst_color[0][0]
+    assert final_color[0][1] == dst_color[0][1]
+    assert final_color[1][0] == dst_color[1][0]
+    assert final_color[1][1] == dst_color[1][1] + src_color
+
+
+def test_pnmimage_mult_sub_image():
+    dst = PNMImage(2, 2)
+    dst.fill(0.5, 0, 0)   #adding color to dst
+    #dst_color will store rgb values at each pixel of dst
+    dst_color = ((dst.get_xel(0, 0), dst.get_xel(0, 1)), (dst.get_xel(1, 0), dst.get_xel(1, 1)))
+
+    src = PNMImage(1, 1)
+    src.fill(0, 0.7, 0)   #adding color to src
+    #src_color will store rgb values at each pixel of src
+    src_color = src.get_xel(0, 0)
+
+    dst.mult_sub_image(src, 1, 1, 0, 0, 1, 1)
+    final_color = ((dst.get_xel(0, 0), dst.get_xel(0, 1)), (dst.get_xel(1, 0), dst.get_xel(1, 1)))
+    assert final_color[0][0] == dst_color[0][0]
+    assert final_color[0][1] == dst_color[0][1]
+    assert final_color[1][0] == dst_color[1][0]
+    assert final_color[1][1][0] == dst_color[1][1][0] * src_color[0] and final_color[1][1][1] == dst_color[1][1][1] * src_color[1] and final_color[1][1][2] == dst_color[1][1][2] * src_color[2]