Panda3D
collisionInvSphere.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 collisionInvSphere.h
10  * @author drose
11  * @date 2005-01-05
12  */
13 
14 #ifndef COLLISIONINVSPHERE_H
15 #define COLLISIONINVSPHERE_H
16 
17 #include "pandabase.h"
18 
19 #include "collisionSphere.h"
20 
21 /**
22  * An inverted sphere: this is a sphere whose collision surface is the inside
23  * surface of the sphere. Everything outside the sphere is solid matter;
24  * everything inside is empty space. Useful for constraining objects to
25  * remain within a spherical perimeter.
26  */
27 class EXPCL_PANDA_COLLIDE CollisionInvSphere : public CollisionSphere {
28 PUBLISHED:
29  INLINE explicit CollisionInvSphere(const LPoint3 &center, PN_stdfloat radius);
30  INLINE explicit CollisionInvSphere(PN_stdfloat cx, PN_stdfloat cy, PN_stdfloat cz, PN_stdfloat radius);
31 
32 protected:
33  INLINE CollisionInvSphere();
34 
35 public:
36  INLINE CollisionInvSphere(const CollisionInvSphere &copy);
37  virtual CollisionSolid *make_copy();
38 
39  virtual PT(CollisionEntry)
40  test_intersection(const CollisionEntry &entry) const;
41 
44 
45  virtual void output(std::ostream &out) const;
46 
47 protected:
48  virtual PT(BoundingVolume) compute_internal_bounds() const;
49 
50  virtual PT(CollisionEntry)
51  test_intersection_from_sphere(const CollisionEntry &entry) const;
52  virtual PT(CollisionEntry)
53  test_intersection_from_line(const CollisionEntry &entry) const;
54  virtual PT(CollisionEntry)
55  test_intersection_from_ray(const CollisionEntry &entry) const;
56  virtual PT(CollisionEntry)
57  test_intersection_from_segment(const CollisionEntry &entry) const;
58  virtual PT(CollisionEntry)
59  test_intersection_from_capsule(const CollisionEntry &entry) const;
60  virtual PT(CollisionEntry)
61  test_intersection_from_box(const CollisionEntry &entry) const;
62 
63  virtual void fill_viz_geom();
64 
65 private:
66  static PStatCollector _volume_pcollector;
67  static PStatCollector _test_pcollector;
68 
69 public:
70  static void register_with_read_factory();
71  virtual void write_datagram(BamWriter *manager, Datagram &me);
72 
73 protected:
74  static TypedWritable *make_CollisionInvSphere(const FactoryParams &params);
75  void fillin(DatagramIterator &scan, BamReader *manager);
76 
77 public:
78  static TypeHandle get_class_type() {
79  return _type_handle;
80  }
81  static void init_type() {
82  CollisionSphere::init_type();
83  register_type(_type_handle, "CollisionInvSphere",
84  CollisionSphere::get_class_type());
85  }
86  virtual TypeHandle get_type() const {
87  return get_class_type();
88  }
89  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
90 
91 private:
92  static TypeHandle _type_handle;
93 };
94 
95 #include "collisionInvSphere.I"
96 
97 #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...
Defines a single collision event.
An inverted sphere: this is a sphere whose collision surface is the inside surface of the sphere.
virtual PStatCollector & get_volume_pcollector()
Returns a PStatCollector that is used to count the number of bounding volume tests made against a sol...
The abstract base class for all things that can collide with other things in the world,...
A spherical collision volume or object.
static void register_with_read_factory()
Factory method to generate a CollisionSphere object.
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