Go to the documentation of this file.
25 TypeHandle BulletTriangleMeshShape::_type_handle;
30 BulletTriangleMeshShape::
31 BulletTriangleMeshShape() :
33 _gimpact_shape(nullptr),
45 BulletTriangleMeshShape::
46 BulletTriangleMeshShape(
BulletTriangleMesh *mesh,
bool dynamic,
bool compress,
bool bvh) :
53 bullet_cat.warning() <<
"mesh is NULL! creating new mesh." << std::endl;
59 bullet_cat.warning() <<
"mesh has zero triangles! adding degenerated triangle." << std::endl;
60 mesh->
add_triangle(LPoint3::zero(), LPoint3::zero(), LPoint3::zero());
69 _gimpact_shape =
new btGImpactMeshShape(mesh->ptr());
70 _gimpact_shape->updateBound();
71 _gimpact_shape->setUserPointer(
this);
79 _bvh_shape =
new btBvhTriangleMeshShape(mesh->ptr(), compress, bvh);
80 _bvh_shape->setUserPointer(
this);
82 _gimpact_shape =
nullptr;
89 BulletTriangleMeshShape::
93 _dynamic = copy._dynamic;
94 _compress = copy._compress;
99 _gimpact_shape =
new btGImpactMeshShape(_mesh->ptr());
100 _gimpact_shape->updateBound();
101 _gimpact_shape->setUserPointer(
this);
102 _bvh_shape =
nullptr;
104 _bvh_shape =
new btBvhTriangleMeshShape(_mesh->ptr(), _compress, _bvh);
105 _bvh_shape->setUserPointer(
this);
106 _gimpact_shape =
nullptr;
113 btCollisionShape *BulletTriangleMeshShape::
120 if (_gimpact_shape) {
121 return _gimpact_shape;
130 void BulletTriangleMeshShape::
131 refit_tree(
const LPoint3 &aabb_min,
const LPoint3 &aabb_max) {
134 nassertv(!aabb_max.is_nan());
135 nassertv(!aabb_max.is_nan());
137 nassertv(this->is_static());
139 _bvh_shape->refitTree(LVecBase3_to_btVector3(aabb_min),
140 LVecBase3_to_btVector3(aabb_max));
180 btStridingMeshInterface *mesh_ptr = _mesh->ptr();
181 nassertr(mesh_ptr !=
nullptr, pi);
184 _gimpact_shape =
new btGImpactMeshShape(mesh_ptr);
185 _gimpact_shape->updateBound();
186 _gimpact_shape->setUserPointer(
this);
187 _gimpact_shape->setMargin(_margin);
189 _bvh_shape =
new btBvhTriangleMeshShape(mesh_ptr, _compress, _bvh);
190 _bvh_shape->setUserPointer(
this);
191 _bvh_shape->setMargin(_margin);
209 param->fillin(scan, manager);
218 void BulletTriangleMeshShape::
void add_triangle(const LPoint3 &p0, const LPoint3 &p1, const LPoint3 &p2, bool remove_duplicate_vertices=false)
Adds a triangle with the indicated coordinates.
Similar to MutexHolder, but for a light mutex.
A class to retrieve the individual data elements previously stored in a Datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
Base class for objects that can be written to and read from Bam files.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
TypeHandle is the identifier used to differentiate C++ class types.
bool get_bool()
Extracts a boolean value.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
void add_bool(bool value)
Adds a boolean value to the datagram.
static void register_with_read_factory()
Tells the BamReader how to create objects of type BulletTriangleMeshShape.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
size_t do_get_num_triangles() const
Returns the number of triangles in this triangle mesh.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...