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 
59  virtual void fill_viz_geom();
60 
61 private:
62  static PStatCollector _volume_pcollector;
63  static PStatCollector _test_pcollector;
64 
65 public:
66  static void register_with_read_factory();
67  virtual void write_datagram(BamWriter *manager, Datagram &me);
68 
69 protected:
70  static TypedWritable *make_CollisionInvSphere(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  CollisionSphere::init_type();
79  register_type(_type_handle, "CollisionInvSphere",
80  CollisionSphere::get_class_type());
81  }
82  virtual TypeHandle get_type() const {
83  return get_class_type();
84  }
85  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
86 
87 private:
88  static TypeHandle _type_handle;
89 };
90 
91 #include "collisionInvSphere.I"
92 
93 #endif
virtual PStatCollector & get_test_pcollector()
Returns a PStatCollector that is used to count the number of intersection tests made against a solid ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
static void register_with_read_factory()
Factory method to generate a CollisionSphere object.
The abstract base class for all things that can collide with other things in the world,...
virtual PStatCollector & get_volume_pcollector()
Returns a PStatCollector that is used to count the number of bounding volume tests made against a sol...
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
A spherical collision volume or object.
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A lightweight class that represents a single element that may be timed and/or counted via stats.
Defines a single collision event.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
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
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
An inverted sphere: this is a sphere whose collision surface is the inside surface of the sphere.