Panda3D
collisionHandlerFloor.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 collisionHandlerFloor.h
10  * @author drose
11  * @date 2002-03-16
12  */
13 
14 #ifndef COLLISIONHANDLERFLOOR_H
15 #define COLLISIONHANDLERFLOOR_H
16 
17 #include "pandabase.h"
18 
20 
21 /**
22  * A specialized kind of CollisionHandler that sets the Z height of the
23  * collider to a fixed linear offset from the highest detected collision point
24  * each frame. It's intended to implement walking around on a floor of
25  * varying height by casting a ray down from the avatar's head.
26  */
27 class EXPCL_PANDA_COLLIDE CollisionHandlerFloor : public CollisionHandlerPhysical {
28 PUBLISHED:
30  virtual ~CollisionHandlerFloor();
31 
32  INLINE void set_offset(PN_stdfloat offset);
33  INLINE PN_stdfloat get_offset() const;
34 
35  INLINE void set_reach(PN_stdfloat reach);
36  INLINE PN_stdfloat get_reach() const;
37 
38  INLINE void set_max_velocity(PN_stdfloat max_vel);
39  INLINE PN_stdfloat get_max_velocity() const;
40 
41 PUBLISHED:
42  MAKE_PROPERTY(offset, get_offset, set_offset);
43  MAKE_PROPERTY(reach, get_reach, set_reach);
44  MAKE_PROPERTY(max_velocity, get_max_velocity, set_max_velocity);
45 
46 protected:
47  PN_stdfloat set_highest_collision(const NodePath &target_node_path, const NodePath &from_node_path, const Entries &entries);
48  virtual bool handle_entries();
49  virtual void apply_linear_force(ColliderDef &def, const LVector3 &force);
50 
51 private:
52  PN_stdfloat _offset;
53  PN_stdfloat _reach;
54  PN_stdfloat _max_velocity;
55 
56 
57 public:
58  static TypeHandle get_class_type() {
59  return _type_handle;
60  }
61  static void init_type() {
62  CollisionHandlerPhysical::init_type();
63  register_type(_type_handle, "CollisionHandlerFloor",
64  CollisionHandlerPhysical::get_class_type());
65  }
66  virtual TypeHandle get_type() const {
67  return get_class_type();
68  }
69  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
70 
71 private:
72  static TypeHandle _type_handle;
73 };
74 
75 #include "collisionHandlerFloor.I"
76 
77 #endif
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.
The abstract base class for a number of CollisionHandlers that have some physical effect on their mov...
A specialized kind of CollisionHandler that sets the Z height of the collider to a fixed linear offse...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:161