Merge branch 'release/1.9.x'

This commit is contained in:
rdb 2016-09-12 00:48:03 +02:00
commit 70f10a70d1
8 changed files with 72 additions and 17 deletions

View File

@ -1848,7 +1848,7 @@ class Packager:
def addEggFile(self, file): def addEggFile(self, file):
# Precompile egg files to bam's. # Precompile egg files to bam's.
np = self.packager.loader.loadModel(file.filename) np = self.packager.loader.loadModel(file.filename, self.packager.loaderOptions)
if not np: if not np:
raise Exception('Could not read egg file %s' % (file.filename)) raise Exception('Could not read egg file %s' % (file.filename))
@ -1862,6 +1862,8 @@ class Packager:
if not bamFile.openRead(file.filename): if not bamFile.openRead(file.filename):
raise Exception('Could not read bam file %s' % (file.filename)) raise Exception('Could not read bam file %s' % (file.filename))
bamFile.getReader().setLoaderOptions(self.packager.loaderOptions)
if not bamFile.resolve(): if not bamFile.resolve():
raise Exception('Could not resolve bam file %s' % (file.filename)) raise Exception('Could not resolve bam file %s' % (file.filename))
@ -2492,6 +2494,14 @@ class Packager:
self.sfxManagerList = None self.sfxManagerList = None
self.musicManager = None self.musicManager = None
# These options will be used when loading models and textures. By
# default we don't load textures beyond the header and don't store
# models in the RAM cache in order to conserve on memory usage.
opts = LoaderOptions()
opts.setFlags(opts.getFlags() | LoaderOptions.LFNoRamCache)
opts.setTextureFlags(opts.getTextureFlags() & ~LoaderOptions.TFPreload)
self.loaderOptions = opts
# This is filled in during readPackageDef(). # This is filled in during readPackageDef().
self.packageList = [] self.packageList = []

View File

@ -462,6 +462,8 @@ class packp3d(p3d):
mainModule('direct.p3d.packp3d') mainModule('direct.p3d.packp3d')
file('packp3d.prc', extract = True, text = "preload-textures false")
class ppackage(p3d): class ppackage(p3d):
# As above, a packaging utility. This is the fully-general ppackage # As above, a packaging utility. This is the fully-general ppackage
@ -475,6 +477,8 @@ class ppackage(p3d):
mainModule('direct.p3d.ppackage') mainModule('direct.p3d.ppackage')
file('ppackage.prc', extract = True, text = "preload-textures false")
class ppatcher(p3d): class ppatcher(p3d):
# A handy utility to go along with ppackage. This builds # A handy utility to go along with ppackage. This builds

View File

@ -909,7 +909,7 @@ class Loader(DirectObject):
orig = origModelList[i].node() orig = origModelList[i].node()
flat = models[i].node() flat = models[i].node()
orig.copyAllProperties(flat) orig.copyAllProperties(flat)
orig.replaceNode(flat) flat.replaceNode(orig)
if callback: if callback:
if gotList: if gotList:

View File

@ -6,6 +6,7 @@ This issue fixes several bugs that were still found in 1.9.2.
* Fix crash using wx/tkinter on Mac as long as want-wx/tk is set * Fix crash using wx/tkinter on Mac as long as want-wx/tk is set
* Fix loading models from 'models' package with models/ prefix * Fix loading models from 'models' package with models/ prefix
* Fix random crashes in task system * Fix random crashes in task system
* Fix various race conditions causing threading issues
* Fix memory leaks in BulletTriangleMesh * Fix memory leaks in BulletTriangleMesh
* Fix loading old models with MovingPart<LMatrix4f> * Fix loading old models with MovingPart<LMatrix4f>
* Improve performance of CPU vertex animation somewhat * Improve performance of CPU vertex animation somewhat
@ -26,12 +27,13 @@ This issue fixes several bugs that were still found in 1.9.2.
* Fix issues with certain Cg shader inputs in DX9 * Fix issues with certain Cg shader inputs in DX9
* Support uint8 index buffers in DX9 * Support uint8 index buffers in DX9
* Fix occasional frame lag when loading a big model asynchronously * Fix occasional frame lag when loading a big model asynchronously
* Fix race condition reading string config var
* Fix interrogate parsing issue with "const static" * Fix interrogate parsing issue with "const static"
* Add back missing libp3pystub.a to Mac OS X SDK * Add back missing libp3pystub.a to Mac OS X SDK
* Fix RAM caching of 2D texture arrays * Fix RAM caching of 2D texture arrays
* Fix Ctrl+C interrupt propagation to runtime applications * Fix Ctrl+C interrupt propagation to runtime applications
* Support for InvSphere, Box and Tube solids in bam2egg * Support for InvSphere, Box and Tube solids in bam2egg
* Add normalized() method to vectors
* asyncFlattenStrong with inPlace=True caused node to disappear
------------------------ RELEASE 1.9.2 ------------------------ ------------------------ RELEASE 1.9.2 ------------------------

View File

@ -54,14 +54,19 @@ print_data(const string &marker) {
void OdeTriMeshData:: void OdeTriMeshData::
remove_data(OdeTriMeshData *data) { remove_data(OdeTriMeshData *data) {
odetrimeshdata_cat.debug() << get_class_type() << "::remove_data(" << data->get_id() << ")" << "\n"; if (odetrimeshdata_cat.is_debug()) {
nassertv(_tri_mesh_data_map != (TriMeshDataMap *)NULL); odetrimeshdata_cat.debug()
TriMeshDataMap::iterator iter; << get_class_type() << "::remove_data(" << data->get_id() << ")" << "\n";
}
if (_tri_mesh_data_map == (TriMeshDataMap *)NULL) {
return;
}
TriMeshDataMap::iterator iter;
for (iter = _tri_mesh_data_map->begin(); for (iter = _tri_mesh_data_map->begin();
iter != _tri_mesh_data_map->end(); iter != _tri_mesh_data_map->end();
++iter) { ++iter) {
if ( iter->second == data ) { if (iter->second == data) {
break; break;
} }
} }
@ -72,7 +77,7 @@ remove_data(OdeTriMeshData *data) {
for (iter = _tri_mesh_data_map->begin(); for (iter = _tri_mesh_data_map->begin();
iter != _tri_mesh_data_map->end(); iter != _tri_mesh_data_map->end();
++iter) { ++iter) {
if ( iter->second == data ) { if (iter->second == data) {
break; break;
} }
} }
@ -150,8 +155,13 @@ operator = (const OdeTriMeshData &other) {
void OdeTriMeshData:: void OdeTriMeshData::
process_model(const NodePath& model, bool &use_normals) { process_model(const NodePath& model, bool &use_normals) {
// TODO: assert if _vertices is something other than 0. // TODO: assert if _vertices is something other than 0.
ostream &out = odetrimeshdata_cat.debug(); if (odetrimeshdata_cat.is_debug()) {
out << "process_model(" << model << ")" << "\n"; odetrimeshdata_cat.debug()
<< "process_model(" << model << ")" << "\n";
}
if (model.is_empty()) {
return;
}
NodePathCollection geomNodePaths = model.find_all_matches("**/+GeomNode"); NodePathCollection geomNodePaths = model.find_all_matches("**/+GeomNode");
if (model.node()->get_type() == GeomNode::get_class_type()) { if (model.node()->get_type() == GeomNode::get_class_type()) {

View File

@ -66,13 +66,22 @@ operator = (const CopyOnWriteObject &copy) {
#ifdef COW_THREADED #ifdef COW_THREADED
/** /**
* See CachedTypedWritableReferenceCount::cache_ref(). * @see CachedTypedWritableReferenceCount::cache_ref()
*/ */
INLINE void CopyOnWriteObject:: INLINE void CopyOnWriteObject::
cache_ref() const { cache_ref() const {
MutexHolder holder(_lock_mutex); MutexHolder holder(_lock_mutex);
CachedTypedWritableReferenceCount::cache_ref(); CachedTypedWritableReferenceCount::cache_ref();
} }
/**
* @see CachedTypedWritableReferenceCount::cache_unref()
*/
INLINE bool CopyOnWriteObject::
cache_unref() const {
MutexHolder holder(_lock_mutex);
return CachedTypedWritableReferenceCount::cache_unref();
}
#endif // COW_THREADED #endif // COW_THREADED
/** /**

View File

@ -48,6 +48,7 @@ PUBLISHED:
#ifdef COW_THREADED #ifdef COW_THREADED
virtual bool unref() const; virtual bool unref() const;
INLINE void cache_ref() const; INLINE void cache_ref() const;
INLINE bool cache_unref() const;
#endif // COW_THREADED #endif // COW_THREADED
protected: protected:

View File

@ -12,7 +12,6 @@
*/ */
#include "copyOnWritePointer.h" #include "copyOnWritePointer.h"
#include "mutexHolder.h"
#include "config_util.h" #include "config_util.h"
#include "config_pipeline.h" #include "config_pipeline.h"
@ -69,7 +68,7 @@ get_write_pointer() {
Thread *current_thread = Thread::get_current_thread(); Thread *current_thread = Thread::get_current_thread();
MutexHolder holder(_cow_object->_lock_mutex); _cow_object->_lock_mutex.acquire();
while (_cow_object->_lock_status == CopyOnWriteObject::LS_locked_write && while (_cow_object->_lock_status == CopyOnWriteObject::LS_locked_write &&
_cow_object->_locking_thread != current_thread) { _cow_object->_locking_thread != current_thread) {
if (util_cat.is_debug()) { if (util_cat.is_debug()) {
@ -89,10 +88,20 @@ get_write_pointer() {
<< "Making copy of " << _cow_object->get_type() << "Making copy of " << _cow_object->get_type()
<< " because it is locked in read mode.\n"; << " because it is locked in read mode.\n";
} }
PT(CopyOnWriteObject) new_object = _cow_object->make_cow_copy(); PT(CopyOnWriteObject) new_object = _cow_object->make_cow_copy();
cache_unref_delete(_cow_object);
// We can't call cache_unref_delete, because we hold the lock.
if (!_cow_object->CachedTypedWritableReferenceCount::cache_unref()) {
_cow_object->_lock_mutex.release();
delete _cow_object;
} else {
_cow_object->_lock_mutex.release();
}
_cow_object = new_object; _cow_object = new_object;
_cow_object->cache_ref(); _cow_object->cache_ref();
_cow_object->_lock_status = CopyOnWriteObject::LS_locked_write;
_cow_object->_locking_thread = current_thread;
} else if (_cow_object->get_cache_ref_count() > 1) { } else if (_cow_object->get_cache_ref_count() > 1) {
// No one else has it specifically read-locked, but there are other // No one else has it specifically read-locked, but there are other
@ -106,9 +115,18 @@ get_write_pointer() {
} }
PT(CopyOnWriteObject) new_object = _cow_object->make_cow_copy(); PT(CopyOnWriteObject) new_object = _cow_object->make_cow_copy();
cache_unref_delete(_cow_object);
// We can't call cache_unref_delete, because we hold the lock.
if (!_cow_object->CachedTypedWritableReferenceCount::cache_unref()) {
_cow_object->_lock_mutex.release();
delete _cow_object;
} else {
_cow_object->_lock_mutex.release();
}
_cow_object = new_object; _cow_object = new_object;
_cow_object->cache_ref(); _cow_object->cache_ref();
_cow_object->_lock_status = CopyOnWriteObject::LS_locked_write;
_cow_object->_locking_thread = current_thread;
} else { } else {
// No other thread has the pointer locked, and we're the only // No other thread has the pointer locked, and we're the only
@ -118,9 +136,10 @@ get_write_pointer() {
// We can't assert that there are no outstanding ordinary references to // We can't assert that there are no outstanding ordinary references to
// it, though, since the creator of the object might have saved himself a // it, though, since the creator of the object might have saved himself a
// reference. // reference.
_cow_object->_lock_status = CopyOnWriteObject::LS_locked_write;
_cow_object->_locking_thread = current_thread;
_cow_object->_lock_mutex.release();
} }
_cow_object->_lock_status = CopyOnWriteObject::LS_locked_write;
_cow_object->_locking_thread = current_thread;
return _cow_object; return _cow_object;
} }