# panda3d.core.ModelPool¶

class ModelPool

This class unifies all references to the same filename, so that multiple attempts to load the same model will return the same pointer. Note that the default behavior is thus to make instances: use with caution. Use the copy_subgraph() method on Node (or use NodePath.copyTo()) to make modifiable copies of the node.

Unlike TexturePool, this class does not automatically resolve the model filenames before loading, so a relative path and an absolute path to the same model will appear to be different filenames.

Inheritance diagram

static hasModel(filename: Filename) → bool

Returns true if the model has ever been loaded, false otherwise. Note that this does not guarantee that the model is still up-to-date.

static verifyModel(filename: Filename) → bool

Loads the given filename up as a model, if it has not already been loaded, and returns true to indicate success, or false to indicate failure. If this returns true, it is probable that a subsequent call to loadModel() with the same model name will return a valid PandaNode.

However, even if this returns true, it is still possible for a subsequent call to loadModel() to fail. This can happen if cache-check-timestamps is true, and the on-disk file is subsequently modified to replace it with an invalid model.

static getModel(filename: Filename, verify: bool) → ModelRoot

Returns the model that has already been previously loaded, or NULL otherwise. If verify is true, it will check if the file is still up-to- date (and hasn’t been modified in the meantime), and if not, will still return NULL.

Return type

ModelRoot

static loadModel(filename: Filename, options: LoaderOptions) → ModelRoot

Loads the given filename up as a model, if it has not already been loaded, and returns the new model. If a model with the same filename was previously loaded, returns that one instead (unless cache-check-timestamps is true and the file has recently changed). If the model file cannot be found, or cannot be loaded for some reason, returns NULL.

Return type

ModelRoot

static addModel(filename: Filename, model: ModelRoot) → None

static addModel(model: ModelRoot) → None

static releaseModel(filename: Filename) → None

Removes the indicated model from the pool, indicating it will never be loaded again; the model may then be freed. If this function is never called, a reference count will be maintained on every model every loaded, and models will never be freed.

static releaseModel(model: ModelRoot) → None

Removes the indicated model from the pool, indicating it will never be loaded again; the model may then be freed. If this function (and garbageCollect()) is never called, a reference count will be maintained on every model every loaded, and models will never be freed.

The model’s get_fullpath() value should not have been changed during its lifetime, or this function may fail to locate it in the pool.

static releaseAllModels() → None

Releases all models in the pool and restores the pool to the empty state.

static garbageCollect() → int

Releases only those models in the pool that have a reference count of exactly 1; i.e. only those models that are not being used outside of the pool. Returns the number of models released.

static listContents() → None

Lists the contents of the model pool to cout.

static listContents(out: ostream) → None

Lists the contents of the model pool to the indicated output stream.

static write(out: ostream) → None

Lists the contents of the model pool to the indicated output stream. Helps with debugging.