Panda3D

physicsCollisionHandler.h

00001 // Filename: physicsCollisionHandler.h
00002 // Created by:  drose (16Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef PHYSICSCOLLISIONHANDLER_H
00016 #define PHYSICSCOLLISIONHANDLER_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "collisionHandlerPusher.h"
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //       Class : PhysicsCollisionHandler
00024 // Description : A specialized kind of CollisionHandler that simply
00025 //               pushes back on things that attempt to move into solid
00026 //               walls.  This also puts forces onto the physics objects
00027 ////////////////////////////////////////////////////////////////////
00028 class EXPCL_PANDAPHYSICS PhysicsCollisionHandler : 
00029     public CollisionHandlerPusher {
00030 PUBLISHED:
00031   PhysicsCollisionHandler();
00032   virtual ~PhysicsCollisionHandler();
00033   
00034   // These setters and getter are a bit of a hack:
00035   INLINE void set_almost_stationary_speed(PN_stdfloat speed);
00036   INLINE PN_stdfloat get_almost_stationary_speed();
00037   
00038   INLINE void set_static_friction_coef(PN_stdfloat coef);
00039   INLINE PN_stdfloat get_static_friction_coef();
00040   
00041   INLINE void set_dynamic_friction_coef(PN_stdfloat coef);
00042   INLINE PN_stdfloat get_dynamic_friction_coef();
00043 
00044 protected:
00045   PN_stdfloat _almost_stationary_speed;
00046   PN_stdfloat _static_friction_coef;
00047   PN_stdfloat _dynamic_friction_coef;
00048 
00049   void apply_friction(
00050       ColliderDef &def, LVector3 &vel, const LVector3& force, PN_stdfloat angle);
00051   virtual void apply_net_shove(
00052       ColliderDef &def, const LVector3 &net_shove,
00053       const LVector3 &force_normal);
00054   virtual void apply_linear_force(ColliderDef &def, const LVector3 &force);
00055 
00056   virtual bool validate_target(const NodePath &target);
00057 
00058 public:
00059   static TypeHandle get_class_type() {
00060     return _type_handle;
00061   }
00062   static void init_type() {
00063     CollisionHandlerPusher::init_type();
00064     register_type(_type_handle, "PhysicsCollisionHandler",
00065                   CollisionHandlerPusher::get_class_type());
00066   }
00067   virtual TypeHandle get_type() const {
00068     return get_class_type();
00069   }
00070   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00071 
00072 private:
00073   static TypeHandle _type_handle;
00074 };
00075 
00076 #include "physicsCollisionHandler.I"
00077 
00078 #endif
00079 
00080 
00081 
 All Classes Functions Variables Enumerations