diff --git a/panda/src/bullet/bulletConvexHullShape.cxx b/panda/src/bullet/bulletConvexHullShape.cxx index d05bafe88d..28c4dbeab0 100644 --- a/panda/src/bullet/bulletConvexHullShape.cxx +++ b/panda/src/bullet/bulletConvexHullShape.cxx @@ -78,7 +78,12 @@ add_array(const PTA_LVecBase3 &points) { // Description: //////////////////////////////////////////////////////////////////// void BulletConvexHullShape:: -add_geom(const Geom *geom) { +add_geom(const Geom *geom, CPT(TransformState) ts) { + + nassertv(geom); + nassertv(ts); + + LMatrix4 m = ts->get_mat(); // Collect points pvector points; @@ -87,7 +92,7 @@ add_geom(const Geom *geom) { GeomVertexReader reader = GeomVertexReader(vdata, InternalName::get_vertex()); while (!reader.is_at_end()) { - points.push_back(reader.get_data3()); + points.push_back(m.xform_point(reader.get_data3())); } // Create shape diff --git a/panda/src/bullet/bulletConvexHullShape.h b/panda/src/bullet/bulletConvexHullShape.h index a168de8e43..dc133d81fc 100644 --- a/panda/src/bullet/bulletConvexHullShape.h +++ b/panda/src/bullet/bulletConvexHullShape.h @@ -38,7 +38,8 @@ PUBLISHED: void add_point(const LPoint3 &p); void add_array(const PTA_LVecBase3 &points); - void add_geom(const Geom *geom); + void add_geom(const Geom *geom, + CPT(TransformState) ts=TransformState::make_identity()); public: virtual btCollisionShape *ptr() const; diff --git a/panda/src/bullet/bulletTriangleMesh.cxx b/panda/src/bullet/bulletTriangleMesh.cxx index fd0591995b..854d414c57 100644 --- a/panda/src/bullet/bulletTriangleMesh.cxx +++ b/panda/src/bullet/bulletTriangleMesh.cxx @@ -101,7 +101,12 @@ get_welding_distance() const { // Description: //////////////////////////////////////////////////////////////////// void BulletTriangleMesh:: -add_geom(const Geom *geom, bool remove_duplicate_vertices) { +add_geom(const Geom *geom, bool remove_duplicate_vertices, CPT(TransformState) ts) { + + nassertv(geom); + nassertv(ts); + + LMatrix4 m = ts->get_mat(); // Collect points pvector points; @@ -110,7 +115,7 @@ add_geom(const Geom *geom, bool remove_duplicate_vertices) { GeomVertexReader reader = GeomVertexReader(vdata, InternalName::get_vertex()); while (!reader.is_at_end()) { - points.push_back(reader.get_data3()); + points.push_back(m.xform_point(reader.get_data3())); } // Convert points diff --git a/panda/src/bullet/bulletTriangleMesh.h b/panda/src/bullet/bulletTriangleMesh.h index 30153911da..ca9ddc2cde 100644 --- a/panda/src/bullet/bulletTriangleMesh.h +++ b/panda/src/bullet/bulletTriangleMesh.h @@ -45,7 +45,8 @@ PUBLISHED: const PTA_int &indices, bool remove_duplicate_vertices=false); void add_geom(const Geom *geom, - bool remove_duplicate_vertices=false); + bool remove_duplicate_vertices=false, + CPT(TransformState) ts=TransformState::make_identity()); void set_welding_distance(PN_stdfloat distance); void preallocate(int num_verts, int num_indices);