David Rose 18 years ago
parent
commit
823bd7a56c
3 changed files with 71 additions and 8 deletions
  1. 63 6
      panda/src/chan/partBundle.cxx
  2. 6 1
      panda/src/chan/partBundle.h
  3. 2 1
      panda/src/putil/bam.h

+ 63 - 6
panda/src/chan/partBundle.cxx

@@ -479,13 +479,24 @@ finalize(BamReader *) {
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: PartBundle::make_PartBundle
+//     Function: PartBundle::write_datagram
+//       Access: Public, Virtual
+//  Description: Writes the contents of this object to the datagram
+//               for shipping out to a Bam file.
+////////////////////////////////////////////////////////////////////
+void PartBundle::
+write_datagram(BamWriter *manager, Datagram &dg) {
+  PartGroup::write_datagram(manager, dg);
+  manager->write_cdata(dg, _cycler);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PartBundle::make_from_bam
 //       Access: Protected
 //  Description: Factory method to generate a PartBundle object
 ////////////////////////////////////////////////////////////////////
 TypedWritable* PartBundle::
-make_PartBundle(const FactoryParams &params)
-{
+make_from_bam(const FactoryParams &params) {
   PartBundle *me = new PartBundle;
   DatagramIterator scan;
   BamReader *manager;
@@ -496,15 +507,30 @@ make_PartBundle(const FactoryParams &params)
   return me;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: PartBundle::fillin
+//       Access: Protected
+//  Description: This internal function is called by make_from_bam to
+//               read in all of the relevant data from the BamFile for
+//               the new PartBundle.
+////////////////////////////////////////////////////////////////////
+void PartBundle::
+fillin(DatagramIterator &scan, BamReader *manager) {
+  PartGroup::fillin(scan, manager);
+
+  if (manager->get_file_minor_ver() >= 10) {
+    manager->read_cdata(scan, _cycler);
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: PartBundle::register_with_factory
 //       Access: Public, Static
 //  Description: Factory method to generate a PartBundle object
 ////////////////////////////////////////////////////////////////////
 void PartBundle::
-register_with_read_factory()
-{
-  BamReader::get_factory()->register_factory(get_class_type(), make_PartBundle);
+register_with_read_factory() {
+  BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -554,6 +580,37 @@ make_copy() const {
   return new CData(*this);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: PartBundle::CData::write_datagram
+//       Access: Public, Virtual
+//  Description: Writes the contents of this object to the datagram
+//               for shipping out to a Bam file.
+////////////////////////////////////////////////////////////////////
+void PartBundle::CData::
+write_datagram(BamWriter *manager, Datagram &dg) const {
+  dg.add_uint8(_blend_type);
+  dg.add_bool(_anim_blend_flag);
+  dg.add_bool(_frame_blend_flag);
+  _root_xform.write_datagram(dg);
+  
+  // The remaining members are strictly dynamic.
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: PartBundle::CData::fillin
+//       Access: Public, Virtual
+//  Description: This internal function is called by make_from_bam to
+//               read in all of the relevant data from the BamFile for
+//               the new PartBundle.
+////////////////////////////////////////////////////////////////////
+void PartBundle::CData::
+fillin(DatagramIterator &scan, BamReader *manager) {
+  _blend_type = (BlendType)scan.get_uint8();
+  _anim_blend_flag = scan.get_bool();
+  _frame_blend_flag = scan.get_bool();
+  _root_xform.read_datagram(scan);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: PartBundle::BlendType output operator
 //  Description:

+ 6 - 1
panda/src/chan/partBundle.h

@@ -151,6 +151,8 @@ private:
     CData(const CData &copy);
 
     virtual CycleData *make_copy() const;
+    virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
+    virtual void fillin(DatagramIterator &scan, BamReader *manager);
     virtual TypeHandle get_parent_type() const {
       return PartBundle::get_class_type();
     }
@@ -173,8 +175,11 @@ private:
 public:
   static void register_with_read_factory();
   virtual void finalize(BamReader *manager);
+  virtual void write_datagram(BamWriter *manager, Datagram &dg);
 
-  static TypedWritable *make_PartBundle(const FactoryParams &params);
+protected:
+  static TypedWritable *make_from_bam(const FactoryParams &params);
+  void fillin(DatagramIterator &scan, BamReader *manager);
 
 public:
 

+ 2 - 1
panda/src/putil/bam.h

@@ -36,7 +36,7 @@ static const unsigned short _bam_major_ver = 6;
 // Bumped to major version 5 on 5/6/05 for new Geom implementation.
 // Bumped to major version 6 on 2/11/06 to factor out PandaNode::CData.
 
-static const unsigned short _bam_minor_ver = 9;
+static const unsigned short _bam_minor_ver = 10;
 // Bumped to minor version 1 on 3/12/06 to add Texture::_compression.
 // Bumped to minor version 2 on 3/17/06 to add PandaNode::_draw_control_mask.
 // Bumped to minor version 3 on 3/21/06 to add Texture::_ram_images.
@@ -46,6 +46,7 @@ static const unsigned short _bam_minor_ver = 9;
 // Bumped to minor version 7 on 2/15/07 to change SliderTable.
 // Bumped to minor version 8 on 5/12/07 to change GeomVertexArrayData::_data.
 // Bumped to minor version 9 on 5/15/07 to add PlaneNode::_clip_effect.
+// Bumped to minor version 10 on 6/19/07 to properly write PartBundles.
 
 
 #endif