25 TypeHandle BulletTriangleMeshShape::_type_handle;
30 BulletTriangleMeshShape::
31 BulletTriangleMeshShape() :
33 _gimpact_shape(nullptr),
45 BulletTriangleMeshShape::
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::
bool get_bool()
Extracts a boolean value.
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Base class for objects that can be written to and read from Bam files.
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
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...
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 add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
void add_bool(bool value)
Adds a boolean value to the 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().
Similar to MutexHolder, but for a light mutex.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
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.
size_t do_get_num_triangles() const
Returns the number of triangles in this triangle mesh.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static void register_with_read_factory()
Tells the BamReader how to create objects of type BulletTriangleMeshShape.
bool read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
void add_triangle(const LPoint3 &p0, const LPoint3 &p1, const LPoint3 &p2, bool remove_duplicate_vertices=false)
Adds a triangle with the indicated coordinates.
A class to retrieve the individual data elements previously stored in a Datagram.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
TypeHandle is the identifier used to differentiate C++ class types.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
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.