20TypeHandle BulletMultiSphereShape::_type_handle;
25BulletMultiSphereShape::
26BulletMultiSphereShape(
const PTA_LVecBase3 &points,
const PTA_stdfloat &radii) {
28 int num_spheres = std::min(points.size(), radii.size());
31 btVector3 *bt_points =
new btVector3[num_spheres];
32 for (
int i=0; i<num_spheres; i++) {
33 bt_points[i] = LVecBase3_to_btVector3(points[i]);
37 btScalar *bt_radii =
new btScalar[num_spheres];
38 for (
int j=0; j<num_spheres; j++) {
39 bt_radii[j] = (PN_stdfloat)radii[j];
43 _shape =
new btMultiSphereShape(bt_points, bt_radii, num_spheres);
44 _shape->setUserPointer(
this);
50BulletMultiSphereShape::
60void BulletMultiSphereShape::
70btCollisionShape *BulletMultiSphereShape::
79int BulletMultiSphereShape::
80get_sphere_count()
const {
83 return _shape->getSphereCount();
89LPoint3 BulletMultiSphereShape::
90get_sphere_pos(
int index)
const {
93 nassertr(index >=0 && index <_shape->getSphereCount(), LPoint3::zero());
94 return btVector3_to_LPoint3(_shape->getSpherePosition(index));
100PN_stdfloat BulletMultiSphereShape::
101get_sphere_radius(
int index)
const {
104 nassertr(index >=0 && index <_shape->getSphereCount(), 0.0);
105 return (PN_stdfloat)_shape->getSphereRadius(index);
127 for (
int i = 0; i < get_sphere_count(); ++i){
128 get_sphere_pos(i).write_datagram(dg);
131 for (
int i = 0; i < get_sphere_count(); ++i){
149 param->fillin(scan, manager);
158void BulletMultiSphereShape::
161 nassertv(_shape ==
nullptr);
167 btVector3 *positions =
new btVector3[sphereCount];
168 for (
int i = 0; i < sphereCount; ++i){
170 pos.read_datagram(scan);
171 positions[i] = LVecBase3_to_btVector3(pos);
174 btScalar *radii =
new btScalar[sphereCount];
175 for (
int i = 0; i < sphereCount; ++i){
179 _shape =
new btMultiSphereShape(positions, radii, sphereCount);
180 _shape->setUserPointer(
this);
181 _shape->setMargin(margin);
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
static void register_with_read_factory()
Tells the BamReader how to create objects of type BulletShape.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
A class to retrieve the individual data elements previously stored in a Datagram.
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
int32_t get_int32()
Extracts a signed 32-bit integer.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_int32(int32_t value)
Adds a signed 32-bit integer to the datagram.
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
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.
Similar to MutexHolder, but for a light mutex.
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.