From 71cb47f94cdd706bde78bdc11017cc79c642cd80 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 22 Apr 2005 21:44:22 +0000 Subject: [PATCH] fix reading bams 4.18 --- panda/src/gobj/qpgeom.cxx | 23 ++++++++++++++++++++++- panda/src/gobj/qpgeom.h | 2 ++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/panda/src/gobj/qpgeom.cxx b/panda/src/gobj/qpgeom.cxx index a2bdb20e62..ebd7993352 100644 --- a/panda/src/gobj/qpgeom.cxx +++ b/panda/src/gobj/qpgeom.cxx @@ -1032,10 +1032,24 @@ make_from_bam(const FactoryParams ¶ms) { parse_params(params, scan, manager); object->fillin(scan, manager); + manager->register_finalize(object); return object; } +//////////////////////////////////////////////////////////////////// +// Function: qpGeom::finalize +// Access: Public, Virtual +// Description: Called by the BamReader to perform any final actions +// needed for setting up the object after all objects +// have been read and all pointers have been completed. +//////////////////////////////////////////////////////////////////// +void qpGeom:: +finalize(BamReader *manager) { + CDWriter cdata(_cycler); + reset_geom_rendering(cdata); +} + //////////////////////////////////////////////////////////////////// // Function: qpGeom::fillin // Access: Protected @@ -1122,6 +1136,9 @@ write_datagram(BamWriter *manager, Datagram &dg) const { dg.add_uint8(_primitive_type); dg.add_uint8(_shade_model); + + // Actually, we shouldn't bother writing out _geom_rendering; we'll + // just throw it away anyway. dg.add_uint16(_geom_rendering); } @@ -1166,7 +1183,11 @@ fillin(DatagramIterator &scan, BamReader *manager) { _primitive_type = (PrimitiveType)scan.get_uint8(); _shade_model = (ShadeModel)scan.get_uint8(); - _geom_rendering = scan.get_uint16(); + + // To be removed: we no longer read _geom_rendering from the bam + // file; instead, we rederive it in finalize(). + scan.get_uint16(); + _got_usage_hint = false; _modified = qpGeom::get_next_modified(); } diff --git a/panda/src/gobj/qpgeom.h b/panda/src/gobj/qpgeom.h index 088b330e20..e8b9907a2f 100644 --- a/panda/src/gobj/qpgeom.h +++ b/panda/src/gobj/qpgeom.h @@ -198,6 +198,8 @@ public: static void register_with_read_factory(); virtual void write_datagram(BamWriter *manager, Datagram &dg); + virtual void finalize(BamReader *manager); + protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager);