Support for optional TransformState when adding a Geom to a triangle mesh or convex mesh.

This commit is contained in:
enn0x 2012-07-10 22:22:59 +00:00
parent 248e4f2672
commit b7eb296cff
4 changed files with 18 additions and 6 deletions

View File

@ -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<LPoint3> 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

View File

@ -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;

View File

@ -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<LPoint3> 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

View File

@ -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);