Browse Source

Add ability to persist ghost nodes.

Stephen Imhoff 4 years ago
parent
commit
cc4701d299

+ 24 - 0
panda/src/bullet/bulletGhostNode.cxx

@@ -171,3 +171,27 @@ do_sync_b2p() {
     _sync_disable = false;
   }
 }
+
+/**
+ * Tells the BamReader how to create objects of type BulletGhostNode.
+ */
+void BulletGhostNode::
+register_with_read_factory() {
+  BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
+}
+
+/**
+ * This function is called by the BamReader's factory when a new object of
+ * this type is encountered in the Bam file.  It should create the ghost node.
+ */
+TypedWritable *BulletGhostNode::
+make_from_bam(const FactoryParams &params) {
+  BulletGhostNode *param = new BulletGhostNode;
+  DatagramIterator scan;
+  BamReader *manager;
+
+  parse_params(params, scan, manager);
+  param->fillin(scan, manager);
+
+  return param;
+}

+ 6 - 0
panda/src/bullet/bulletGhostNode.h

@@ -59,6 +59,12 @@ private:
 
   void do_transform_changed();
 
+public:
+  static void register_with_read_factory();
+
+protected:
+  static TypedWritable *make_from_bam(const FactoryParams &params);
+
 public:
   static TypeHandle get_class_type() {
     return _type_handle;

+ 1 - 0
panda/src/bullet/config_bullet.cxx

@@ -189,6 +189,7 @@ init_libbullet() {
   BulletDebugNode::register_with_read_factory();
   BulletPlaneShape::register_with_read_factory();
   BulletRigidBodyNode::register_with_read_factory();
+  BulletGhostNode::register_with_read_factory();
   BulletSphereShape::register_with_read_factory();
   BulletTriangleMesh::register_with_read_factory();
   BulletTriangleMeshShape::register_with_read_factory();