diff --git a/panda/src/chan/partBundle.cxx b/panda/src/chan/partBundle.cxx index c14e65f90a..948fc7cdda 100644 --- a/panda/src/chan/partBundle.cxx +++ b/panda/src/chan/partBundle.cxx @@ -188,6 +188,10 @@ apply_transform(const TransformState *transform) { bool inserted = _applied_transforms.insert(AppliedTransforms::value_type(transform, new_bundle)).second; nassertr(inserted, new_bundle); } + + // Make sure the new transform gets immediately applied to all of + // the joints. + new_bundle->force_update(); return new_bundle; } diff --git a/panda/src/chan/partBundleNode.cxx b/panda/src/chan/partBundleNode.cxx index 653555e55f..5f5ff3dc0e 100644 --- a/panda/src/chan/partBundleNode.cxx +++ b/panda/src/chan/partBundleNode.cxx @@ -57,6 +57,10 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, PT(PartBundle) new_bundle = bundle->apply_transform(attribs._transform); update_bundle(handle, new_bundle); } + + // Make sure the Geom bounding volumes get recomputed due to this + // update. + r_mark_geom_bounds_stale(Thread::get_current_thread()); } } diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index 1a6e99ebc8..051da2493e 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -1060,6 +1060,22 @@ animate_vertices(bool force, Thread *current_thread) const { return cdataw->_animated_vertices; } +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexData::clear_animated_vertices +// Access: Published +// Description: Removes the cache of animated vertices computed by a +// previous call to animate_vertices() within the same +// frame. This will force the next call to +// animate_vertices() to recompute these values from +// scratch. Normally it is not necessary to call this. +//////////////////////////////////////////////////////////////////// +void GeomVertexData:: +clear_animated_vertices() { + CDWriter cdata(_cycler, true); + cdata->_animated_vertices_modified.clear(); + cdata->_animated_vertices.clear(); +} + //////////////////////////////////////////////////////////////////// // Function: GeomVertexData::bytewise_copy // Access: Private, Static diff --git a/panda/src/gobj/geomVertexData.h b/panda/src/gobj/geomVertexData.h index 388b6a5161..07b0dbc6d7 100644 --- a/panda/src/gobj/geomVertexData.h +++ b/panda/src/gobj/geomVertexData.h @@ -150,6 +150,7 @@ PUBLISHED: CPT(GeomVertexData) reverse_normals() const; CPT(GeomVertexData) animate_vertices(bool force, Thread *current_thread) const; + void clear_animated_vertices(); PT(GeomVertexData) replace_column(InternalName *name, int num_components, diff --git a/panda/src/pgraph/geomNode.cxx b/panda/src/pgraph/geomNode.cxx index e64111fa83..b588890c0a 100644 --- a/panda/src/pgraph/geomNode.cxx +++ b/panda/src/pgraph/geomNode.cxx @@ -832,6 +832,30 @@ do_premunge(GraphicsStateGuardianBase *gsg, CLOSE_ITERATE_CURRENT_AND_UPSTREAM(_cycler); } +//////////////////////////////////////////////////////////////////// +// Function: GeomNode::r_mark_geom_bounds_stale +// Access: Protected, Virtual +// Description: Recursively calls Geom::mark_bounds_stale() on every +// Geom at this node and below. +//////////////////////////////////////////////////////////////////// +void GeomNode:: +r_mark_geom_bounds_stale(Thread *current_thread) { + OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { + CDStageWriter cdata(_cycler, pipeline_stage, current_thread); + + GeomList::iterator gi; + PT(GeomList) geoms = cdata->modify_geoms(); + for (gi = geoms->begin(); gi != geoms->end(); ++gi) { + GeomEntry &entry = (*gi); + entry._geom.get_read_pointer()->mark_bounds_stale(); + } + } + CLOSE_ITERATE_CURRENT_AND_UPSTREAM(_cycler); + mark_internal_bounds_stale(); + + PandaNode::r_mark_geom_bounds_stale(current_thread); +} + //////////////////////////////////////////////////////////////////// // Function: GeomNode::compute_internal_bounds // Access: Protected, Virtual diff --git a/panda/src/pgraph/geomNode.h b/panda/src/pgraph/geomNode.h index a9620f9e68..7b5f699a6d 100644 --- a/panda/src/pgraph/geomNode.h +++ b/panda/src/pgraph/geomNode.h @@ -100,6 +100,7 @@ public: GeomTransformer &transformer); protected: + virtual void r_mark_geom_bounds_stale(Thread *current_thread); virtual void compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, int &internal_vertices, int pipeline_stage, diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index 098f1d1465..fa56a6e380 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -2641,6 +2641,29 @@ force_bounds_stale(int pipeline_stage, Thread *current_thread) { } } +//////////////////////////////////////////////////////////////////// +// Function: PandaNode::r_mark_geom_bounds_stale +// Access: Protected, Virtual +// Description: Recursively calls Geom::mark_bounds_stale() on every +// Geom at this node and below. +//////////////////////////////////////////////////////////////////// +void PandaNode:: +r_mark_geom_bounds_stale(Thread *current_thread) { + Children children = get_children(current_thread); + + int i; + for (i = 0; i < children.get_num_children(); i++) { + PandaNode *child = children.get_child(i); + child->r_mark_geom_bounds_stale(current_thread); + } + + Stashed stashed = get_stashed(current_thread); + for (i = 0; i < stashed.get_num_stashed(); i++) { + PandaNode *child = stashed.get_stashed(i); + child->r_mark_geom_bounds_stale(current_thread); + } +} + //////////////////////////////////////////////////////////////////// // Function: PandaNode::compute_internal_bounds // Access: Protected, Virtual diff --git a/panda/src/pgraph/pandaNode.h b/panda/src/pgraph/pandaNode.h index 6fa5bef7ac..b265cd1fa5 100644 --- a/panda/src/pgraph/pandaNode.h +++ b/panda/src/pgraph/pandaNode.h @@ -308,6 +308,8 @@ protected: void force_bounds_stale(int pipeline_stage, Thread *current_thread); INLINE void mark_internal_bounds_stale(int pipeline_stage, Thread *current_thread); + virtual void r_mark_geom_bounds_stale(Thread *current_thread); + virtual void compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, int &internal_vertices, int pipeline_stage,