Panda3D
physicsCollisionHandler.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 physicsCollisionHandler.h
10  * @author drose
11  * @date 2002-03-16
12  */
13 
14 #ifndef PHYSICSCOLLISIONHANDLER_H
15 #define PHYSICSCOLLISIONHANDLER_H
16 
17 #include "pandabase.h"
18 
19 #include "collisionHandlerPusher.h"
20 
21 /**
22  * A specialized kind of CollisionHandler that simply pushes back on things
23  * that attempt to move into solid walls. This also puts forces onto the
24  * physics objects
25  */
26 class EXPCL_PANDA_PHYSICS PhysicsCollisionHandler :
27  public CollisionHandlerPusher {
28 PUBLISHED:
30  virtual ~PhysicsCollisionHandler();
31 
32  // These setters and getter are a bit of a hack:
33  INLINE void set_almost_stationary_speed(PN_stdfloat speed);
34  INLINE PN_stdfloat get_almost_stationary_speed();
35 
36  INLINE void set_static_friction_coef(PN_stdfloat coef);
37  INLINE PN_stdfloat get_static_friction_coef();
38 
39  INLINE void set_dynamic_friction_coef(PN_stdfloat coef);
40  INLINE PN_stdfloat get_dynamic_friction_coef();
41 
42 protected:
43  PN_stdfloat _almost_stationary_speed;
44  PN_stdfloat _static_friction_coef;
45  PN_stdfloat _dynamic_friction_coef;
46 
47  void apply_friction(
48  ColliderDef &def, LVector3 &vel, const LVector3& force, PN_stdfloat angle);
49  virtual void apply_net_shove(
50  ColliderDef &def, const LVector3 &net_shove,
51  const LVector3 &force_normal);
52  virtual void apply_linear_force(ColliderDef &def, const LVector3 &force);
53 
54  virtual bool validate_target(const NodePath &target);
55 
56 public:
57  static TypeHandle get_class_type() {
58  return _type_handle;
59  }
60  static void init_type() {
61  CollisionHandlerPusher::init_type();
62  register_type(_type_handle, "PhysicsCollisionHandler",
63  CollisionHandlerPusher::get_class_type());
64  }
65  virtual TypeHandle get_type() const {
66  return get_class_type();
67  }
68  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
69 
70 private:
71  static TypeHandle _type_handle;
72 };
73 
75 
76 #endif
A specialized kind of CollisionHandler that simply pushes back on things that attempt to move into so...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:159
A specialized kind of CollisionHandler that simply pushes back on things that attempt to move into so...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
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