mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
fix crash loading multiple maya files in one sessions
This commit is contained in:
parent
49f10b70e7
commit
70f8a82a0d
@ -191,6 +191,23 @@ get_node(int n) const {
|
|||||||
return _nodes[n];
|
return _nodes[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MayaNodeTree::clear
|
||||||
|
// Access: Public
|
||||||
|
// Description: Resets the entire tree in preparation for
|
||||||
|
// repopulating with a new scene.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void MayaNodeTree::
|
||||||
|
clear() {
|
||||||
|
_root = new MayaNodeDesc;
|
||||||
|
_fps = 0.0;
|
||||||
|
_egg_data = (EggData *)NULL;
|
||||||
|
_egg_root = (EggGroupNode *)NULL;
|
||||||
|
_skeleton_node = (EggGroupNode *)NULL;
|
||||||
|
_nodes_by_path.clear();
|
||||||
|
_nodes.clear();
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: MayaNodeTree::clear_egg
|
// Function: MayaNodeTree::clear_egg
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -41,6 +41,7 @@ public:
|
|||||||
int get_num_nodes() const;
|
int get_num_nodes() const;
|
||||||
MayaNodeDesc *get_node(int n) const;
|
MayaNodeDesc *get_node(int n) const;
|
||||||
|
|
||||||
|
void clear();
|
||||||
void clear_egg(EggData *egg_data, EggGroupNode *egg_root,
|
void clear_egg(EggData *egg_data, EggGroupNode *egg_root,
|
||||||
EggGroupNode *skeleton_node);
|
EggGroupNode *skeleton_node);
|
||||||
EggGroup *get_egg_group(MayaNodeDesc *node_desc);
|
EggGroup *get_egg_group(MayaNodeDesc *node_desc);
|
||||||
|
@ -181,6 +181,13 @@ convert_file(const Filename &filename) {
|
|||||||
<< "Maya is not available.\n";
|
<< "Maya is not available.\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We must ensure our Maya pointers are cleared before we reset the
|
||||||
|
// Maya scene, because resetting the Maya scene will invalidate all
|
||||||
|
// the Maya pointers we are holding and cause a crash if we try to
|
||||||
|
// free them later.
|
||||||
|
clear();
|
||||||
|
|
||||||
if (!_maya->read(filename)) {
|
if (!_maya->read(filename)) {
|
||||||
mayaegg_cat.error()
|
mayaegg_cat.error()
|
||||||
<< "Unable to read " << filename << "\n";
|
<< "Unable to read " << filename << "\n";
|
||||||
@ -220,8 +227,8 @@ get_input_units() {
|
|||||||
bool MayaToEggConverter::
|
bool MayaToEggConverter::
|
||||||
convert_maya(bool from_selection) {
|
convert_maya(bool from_selection) {
|
||||||
_from_selection = from_selection;
|
_from_selection = from_selection;
|
||||||
_textures.clear();
|
|
||||||
_shaders.clear();
|
clear();
|
||||||
|
|
||||||
if (!open_api()) {
|
if (!open_api()) {
|
||||||
mayaegg_cat.error()
|
mayaegg_cat.error()
|
||||||
@ -364,11 +371,26 @@ open_api() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void MayaToEggConverter::
|
void MayaToEggConverter::
|
||||||
close_api() {
|
close_api() {
|
||||||
// We have to clear the shaders before we release the Maya API.
|
// We have to clear the shaders, at least, before we release the
|
||||||
_shaders.clear();
|
// Maya API.
|
||||||
|
clear();
|
||||||
_maya.clear();
|
_maya.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: MayaToEggConverter::clear
|
||||||
|
// Access: Public
|
||||||
|
// Description: Frees all of the Maya pointers kept within this
|
||||||
|
// object, in preparation for loading a new scene or
|
||||||
|
// releasing the Maya API.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void MayaToEggConverter::
|
||||||
|
clear() {
|
||||||
|
_tree.clear();
|
||||||
|
_textures.clear();
|
||||||
|
_shaders.clear();
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: MayaToEggConverter::convert_flip
|
// Function: MayaToEggConverter::convert_flip
|
||||||
// Access: Private
|
// Access: Private
|
||||||
@ -561,6 +583,7 @@ process_model_node(MayaNodeDesc *node_desc) {
|
|||||||
MFnDagNode dag_node(dag_path, &status);
|
MFnDagNode dag_node(dag_path, &status);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
status.perror("MFnDagNode constructor");
|
status.perror("MFnDagNode constructor");
|
||||||
|
mayaegg_cat.error() << dag_path.fullPathName() << "\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +80,7 @@ public:
|
|||||||
void close_api();
|
void close_api();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void clear();
|
||||||
bool convert_flip(double start_frame, double end_frame,
|
bool convert_flip(double start_frame, double end_frame,
|
||||||
double frame_inc, double output_frame_rate);
|
double frame_inc, double output_frame_rate);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user