mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
Merge branch 'release/1.10.x'
This commit is contained in:
commit
e2177ecbdb
@ -144,7 +144,7 @@ class ControlManager:
|
|||||||
def delete(self):
|
def delete(self):
|
||||||
assert self.notify.debugCall(id(self))
|
assert self.notify.debugCall(id(self))
|
||||||
self.disable()
|
self.disable()
|
||||||
for controls in self.controls.keys():
|
for controls in list(self.controls.keys()):
|
||||||
self.remove(controls)
|
self.remove(controls)
|
||||||
del self.controls
|
del self.controls
|
||||||
del self.currentControls
|
del self.currentControls
|
||||||
|
38
direct/src/dist/commands.py
vendored
38
direct/src/dist/commands.py
vendored
@ -571,15 +571,19 @@ class build_apps(setuptools.Command):
|
|||||||
libdir = os.path.dirname(dtool_fn.to_os_specific())
|
libdir = os.path.dirname(dtool_fn.to_os_specific())
|
||||||
etcdir = os.path.join(libdir, '..', 'etc')
|
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'):
|
if fn.lower().endswith('.prc'):
|
||||||
with open(os.path.join(etcdir, fn)) as f:
|
with open(os.path.join(etcdir, fn)) as f:
|
||||||
prcstring += f.read()
|
prcstring += f.read()
|
||||||
else:
|
else:
|
||||||
etcfiles = [i for i in p3dwhl.namelist() if i.endswith('.prc')]
|
etcfiles = [i for i in p3dwhl.namelist() if i.endswith('.prc')]
|
||||||
|
etcfiles.sort(reverse=True)
|
||||||
for fn in etcfiles:
|
for fn in etcfiles:
|
||||||
with p3dwhl.open(fn) as f:
|
with p3dwhl.open(fn) as f:
|
||||||
prcstring += f.read().decode('utf8')
|
prcstring += f.read().decode('utf8')
|
||||||
|
|
||||||
user_prcstring = self.extra_prc_data
|
user_prcstring = self.extra_prc_data
|
||||||
for fn in self.extra_prc_files:
|
for fn in self.extra_prc_files:
|
||||||
with open(fn) as f:
|
with open(fn) as f:
|
||||||
@ -598,12 +602,33 @@ class build_apps(setuptools.Command):
|
|||||||
for ln in prcstr.split('\n'):
|
for ln in prcstr.split('\n'):
|
||||||
ln = ln.strip()
|
ln = ln.strip()
|
||||||
useline = True
|
useline = True
|
||||||
|
|
||||||
if ln.startswith('#') or not ln:
|
if ln.startswith('#') or not ln:
|
||||||
continue
|
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:
|
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
|
useline = False
|
||||||
if warn_on_missing_plugin:
|
if warn_on_missing_plugin:
|
||||||
self.warn(
|
self.warn(
|
||||||
@ -611,7 +636,10 @@ class build_apps(setuptools.Command):
|
|||||||
)
|
)
|
||||||
break
|
break
|
||||||
if useline:
|
if useline:
|
||||||
out.append(ln)
|
if value:
|
||||||
|
out.append(var + ' ' + value)
|
||||||
|
else:
|
||||||
|
out.append(var)
|
||||||
return out
|
return out
|
||||||
prcexport = parse_prc(prcstring, 0) + parse_prc(user_prcstring, 1)
|
prcexport = parse_prc(prcstring, 0) + parse_prc(user_prcstring, 1)
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ add_ostream(std::ostream *out, bool delete_later) {
|
|||||||
INLINE bool MultiplexStream::
|
INLINE bool MultiplexStream::
|
||||||
add_stdio_file(FILE *fout, bool close_when_done) {
|
add_stdio_file(FILE *fout, bool close_when_done) {
|
||||||
_msb.add_output(MultiplexStreamBuf::BT_line,
|
_msb.add_output(MultiplexStreamBuf::BT_line,
|
||||||
MultiplexStreamBuf::OT_ostream,
|
MultiplexStreamBuf::OT_stdio,
|
||||||
nullptr, fout, close_when_done);
|
nullptr, fout, close_when_done);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -481,6 +481,34 @@ flush_level() {
|
|||||||
_cache_counter.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
|
#ifndef CPPPARSER
|
||||||
/**
|
/**
|
||||||
* Handy templated version of get_attrib that casts to the right type.
|
* Handy templated version of get_attrib that casts to the right type.
|
||||||
@ -533,7 +561,7 @@ check_hash() const {
|
|||||||
*/
|
*/
|
||||||
INLINE bool RenderState::
|
INLINE bool RenderState::
|
||||||
do_cache_unref() const {
|
do_cache_unref() const {
|
||||||
cache_unref_only();
|
NodeCachedReferenceCount::cache_unref_only();
|
||||||
return unref();
|
return unref();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,6 +169,11 @@ public:
|
|||||||
INLINE void get_attrib_def(CPT(AttribType) &attrib) const;
|
INLINE void get_attrib_def(CPT(AttribType) &attrib) const;
|
||||||
#endif // CPPPARSER
|
#endif // CPPPARSER
|
||||||
|
|
||||||
|
INLINE void cache_ref_only() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
INLINE void cache_unref_only() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
INLINE void check_hash() const;
|
INLINE void check_hash() const;
|
||||||
bool validate_filled_slots() const;
|
bool validate_filled_slots() const;
|
||||||
|
@ -753,6 +753,34 @@ flush_level() {
|
|||||||
_cache_counter.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
|
* Reimplements NodeReferenceCount::node_unref(). We do this because we have
|
||||||
* a non-virtual unref() method.
|
* a non-virtual unref() method.
|
||||||
@ -769,7 +797,7 @@ do_node_unref() const {
|
|||||||
*/
|
*/
|
||||||
INLINE bool TransformState::
|
INLINE bool TransformState::
|
||||||
do_cache_unref() const {
|
do_cache_unref() const {
|
||||||
cache_unref_only();
|
NodeCachedReferenceCount::cache_unref_only();
|
||||||
return unref();
|
return unref();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +213,11 @@ public:
|
|||||||
|
|
||||||
INLINE static void flush_level();
|
INLINE static void flush_level();
|
||||||
|
|
||||||
|
INLINE void cache_ref_only() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
INLINE void cache_unref_only() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
INLINE bool do_cache_unref() const;
|
INLINE bool do_cache_unref() const;
|
||||||
INLINE bool do_node_unref() const;
|
INLINE bool do_node_unref() const;
|
||||||
|
@ -1176,7 +1176,7 @@ add_sub_image(const PNMImage ©, int xto, int yto,
|
|||||||
if (has_alpha() && copy.has_alpha()) {
|
if (has_alpha() && copy.has_alpha()) {
|
||||||
for (y = ymin; y < ymax; y++) {
|
for (y = ymin; y < ymax; y++) {
|
||||||
for (x = xmin; x < xmax; x++) {
|
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 ©, int xto, int yto,
|
|||||||
for (y = ymin; y < ymax; y++) {
|
for (y = ymin; y < ymax; y++) {
|
||||||
for (x = xmin; x < xmax; x++) {
|
for (x = xmin; x < xmax; x++) {
|
||||||
LRGBColorf rgb1 = get_xel(x, y);
|
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,
|
set_xel(x, y,
|
||||||
rgb1[0] + rgb2[0] * pixel_scale,
|
rgb1[0] + rgb2[0] * pixel_scale,
|
||||||
rgb1[1] + rgb2[1] * pixel_scale,
|
rgb1[1] + rgb2[1] * pixel_scale,
|
||||||
@ -1210,7 +1210,7 @@ mult_sub_image(const PNMImage ©, int xto, int yto,
|
|||||||
if (has_alpha() && copy.has_alpha()) {
|
if (has_alpha() && copy.has_alpha()) {
|
||||||
for (y = ymin; y < ymax; y++) {
|
for (y = ymin; y < ymax; y++) {
|
||||||
for (x = xmin; x < xmax; x++) {
|
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 ©, int xto, int yto,
|
|||||||
for (y = ymin; y < ymax; y++) {
|
for (y = ymin; y < ymax; y++) {
|
||||||
for (x = xmin; x < xmax; x++) {
|
for (x = xmin; x < xmax; x++) {
|
||||||
LRGBColorf rgb1 = get_xel(x, y);
|
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,
|
set_xel(x, y,
|
||||||
rgb1[0] * rgb2[0] * pixel_scale,
|
rgb1[0] * rgb2[0] * pixel_scale,
|
||||||
rgb1[1] * rgb2[1] * pixel_scale,
|
rgb1[1] * rgb2[1] * pixel_scale,
|
||||||
|
@ -70,3 +70,40 @@ def test_pnmimage_quantize():
|
|||||||
assert col.b in (0, 1)
|
assert col.b in (0, 1)
|
||||||
|
|
||||||
assert max_dist < 0.1 ** 2
|
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]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user