Panda3D
bulletTriangleMeshShape.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file bulletTriangleMeshShape.h
10  * @author enn0x
11  * @date 2010-02-09
12  */
13 
14 #ifndef __BULLET_TRIANGLE_MESH_SHAPE_H__
15 #define __BULLET_TRIANGLE_MESH_SHAPE_H__
16 
17 #include "pandabase.h"
18 
19 #include "bullet_includes.h"
20 #include "bulletShape.h"
21 
22 #include "factoryParams.h"
23 #include "luse.h"
24 
25 class BulletTriangleMesh;
26 
27 /**
28  *
29  */
30 class EXPCL_PANDABULLET BulletTriangleMeshShape : public BulletShape {
31 private:
32  INLINE BulletTriangleMeshShape();
33 
34 PUBLISHED:
35  explicit BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress=true, bool bvh=true);
37  INLINE ~BulletTriangleMeshShape();
38 
39  void refit_tree(const LPoint3 &aabb_min, const LPoint3 &aabb_max);
40 
41  INLINE bool is_static() const;
42  INLINE bool is_dynamic() const;
43 
44  MAKE_PROPERTY(static, is_static);
45  MAKE_PROPERTY(dynamic, is_dynamic);
46 
47 public:
48  virtual btCollisionShape *ptr() const;
49 
50 private:
51  btBvhTriangleMeshShape *_bvh_shape;
52  btGImpactMeshShape *_gimpact_shape;
53 
54  PT(BulletTriangleMesh) _mesh;
55 
56  // Stored temporarily during bam read.
57  PN_stdfloat _margin;
58 
59  bool _dynamic : 1;
60  bool _compress : 1;
61  bool _bvh : 1;
62 
63 public:
64  static void register_with_read_factory();
65  virtual void write_datagram(BamWriter *manager, Datagram &dg);
67  BamReader *manager);
68 
69 protected:
70  static TypedWritable *make_from_bam(const FactoryParams &params);
71  void fillin(DatagramIterator &scan, BamReader *manager);
72 
73 public:
74  static TypeHandle get_class_type() {
75  return _type_handle;
76  }
77  static void init_type() {
78  BulletShape::init_type();
79  register_type(_type_handle, "BulletTriangleMeshShape",
80  BulletShape::get_class_type());
81  }
82  virtual TypeHandle get_type() const {
83  return get_class_type();
84  }
85  virtual TypeHandle force_init_type() {
86  init_type();
87  return get_class_type();
88  }
89 
90 private:
91  static TypeHandle _type_handle;
92 };
93 
95 
96 #endif // __BULLET_TRIANGLE_MESH_SHAPE_H__
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...
Definition: bamReader.h:110
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
This is our own Panda specialization on the default STL list.
Definition: plist.h:35
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.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
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().
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38