Panda3D
collisionCone.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 collisionCone.h
10  * @author rdb
11  * @date 2021-01-29
12  */
13 
14 #ifndef COLLISIONCONE_H
15 #define COLLISIONCONE_H
16 
17 #include "pandabase.h"
18 #include "collisionSolid.h"
19 
20 /**
21  * This implements a conical solid consisting a circular base with a pointy tip.
22  */
23 class EXPCL_PANDA_COLLIDE CollisionCone : public CollisionSolid {
24 private:
25  INLINE CollisionCone();
26 
27 PUBLISHED:
28  INLINE explicit CollisionCone(PN_stdfloat radius, PN_stdfloat height);
29  INLINE CollisionCone(const CollisionCone &copy);
30 
31  virtual LPoint3 get_collision_origin() const;
32 
33 public:
34  virtual CollisionSolid *make_copy();
35 
36  virtual void xform(const LMatrix4 &mat);
37 
38  virtual PStatCollector &get_volume_pcollector();
40 
41  virtual void output(std::ostream &out) const;
42 
43  INLINE static void flush_level();
44 
45 public:
46  INLINE void set_radius(PN_stdfloat radius);
47  INLINE PN_stdfloat get_radius() const;
48 
49  INLINE const LPoint3 &get_apex() const;
50 
51 PUBLISHED:
52  MAKE_PROPERTY(radius, get_radius, set_radius);
53  MAKE_PROPERTY(apex, get_apex);
54 
55 protected:
56  virtual PT(BoundingVolume) compute_internal_bounds() const;
57 
58 protected:
59  virtual PT(CollisionEntry)
60  test_intersection_from_sphere(const CollisionEntry &entry) const;
61 
62  virtual void fill_viz_geom();
63 
64 private:
65  LPoint3 _apex;
66  PN_stdfloat _radius;
67 
68  static PStatCollector _volume_pcollector;
69  static PStatCollector _test_pcollector;
70 
71 public:
72  static void register_with_read_factory();
73  virtual void write_datagram(BamWriter *manager, Datagram &dg);
74 
75 protected:
76  static TypedWritable *make_from_bam(const FactoryParams &params);
77  void fillin(DatagramIterator &scan, BamReader *manager);
78 
79 public:
80  static TypeHandle get_class_type() {
81  return _type_handle;
82  }
83  static void init_type() {
84  CollisionSolid::init_type();
85  register_type(_type_handle, "CollisionCone",
86  CollisionSolid::get_class_type());
87  }
88  virtual TypeHandle get_type() const {
89  return get_class_type();
90  }
91  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
92 
93 private:
94  static TypeHandle _type_handle;
95 
96  friend class CollisionBox;
97 };
98 
99 #include "collisionCone.I"
100 
101 #endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
A cuboid collision volume or object.
Definition: collisionBox.h:27
This implements a conical solid consisting a circular base with a pointy tip.
Definition: collisionCone.h:23
Defines a single collision event.
The abstract base class for all things that can collide with other things in the world,...
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
virtual PStatCollector & get_test_pcollector()
Returns a PStatCollector that is used to count the number of intersection tests made against a solid ...
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
A lightweight class that represents a single element that may be timed and/or counted via stats.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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