Panda3D
modelFlattenRequest.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file modelFlattenRequest.cxx
10  * @author drose
11  * @date 2007-03-30
12  */
13 
14 #include "modelFlattenRequest.h"
15 #include "nodePath.h"
16 
17 TypeHandle ModelFlattenRequest::_type_handle;
18 
19 /**
20  * Performs the task: that is, copies and flattens the model.
21  */
22 AsyncTask::DoneStatus ModelFlattenRequest::
23 do_task() {
24  // We make another instance of the original node, so we can safely flatten
25  // that without affecting the original copy.
26  NodePath np("flatten_root");
27 
28  // Except if we try to attach a node without parents, this will cause the
29  // original NodePath to be affected, so we have to make a (shallow) copy.
30  if (_orig->get_num_parents() == 0) {
31  PT(PandaNode) copy = _orig->make_copy();
32  copy->copy_children(_orig);
33  np.attach_new_node(copy);
34  } else {
35  np.attach_new_node(_orig);
36  }
37  np.flatten_strong();
38 
39  set_result(np.get_child(0).node());
40 
41  // Don't continue the task; we're done.
42  return DS_done;
43 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_result(std::nullptr_t)
Sets this future's result.
Definition: asyncFuture.I:92
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:161