Browse Source

Switch from setVelocityForTimeInterval to setWalkDirection.

enn0x 14 years ago
parent
commit
212ed1e510

+ 2 - 1
panda/src/bullet/bulletCharacterControllerNode.cxx

@@ -227,7 +227,8 @@ sync_p2b(float dt) {
     v = LVecBase3f_to_btVector3(_linear_velocity);
     v = LVecBase3f_to_btVector3(_linear_velocity);
   }
   }
 
 
-  _character->setVelocityForTimeInterval(v, dt);
+  //_character->setVelocityForTimeInterval(v, dt);
+  _character->setWalkDirection(v * dt);
   _angular_velocity = 0.0f;
   _angular_velocity = 0.0f;
 }
 }
 
 

+ 27 - 0
panda/src/bullet/bulletGhostNode.cxx

@@ -28,6 +28,7 @@ BulletGhostNode(const char *name) : BulletBodyNode(name) {
   // Synchronised transform
   // Synchronised transform
   _sync = TransformState::make_identity();
   _sync = TransformState::make_identity();
   _sync_disable = false;
   _sync_disable = false;
+  _sync_local = false;
 
 
   // Initial transform
   // Initial transform
   btTransform trans = btTransform::getIdentity();
   btTransform trans = btTransform::getIdentity();
@@ -52,6 +53,32 @@ get_object() const {
   return _ghost;
   return _ghost;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: BulletGhostNode::parents_changed
+//       Access: Protected
+//  Description:
+////////////////////////////////////////////////////////////////////
+void BulletGhostNode::
+parents_changed() {
+
+  Parents parents = get_parents();
+  for (int i=0; i < parents.get_num_parents(); ++i) {
+    PandaNode *parent = parents.get_parent(i);
+    TypeHandle type = parent->get_type();
+
+    if (BulletRigidBodyNode::get_class_type() == type ||
+        BulletSoftBodyNode::get_class_type() == type ||
+        BulletGhostNode::get_class_type() == type ||
+        BulletCharacterControllerNode::get_class_type() == type) {
+
+      _sync_local = true;
+      return;
+    }
+  }
+
+  _sync_local = false;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: BulletGhostNode::transform_changed
 //     Function: BulletGhostNode::transform_changed
 //       Access: Protected
 //       Access: Protected

+ 2 - 0
panda/src/bullet/bulletGhostNode.h

@@ -48,11 +48,13 @@ public:
   void sync_b2p();
   void sync_b2p();
 
 
 protected:
 protected:
+  virtual void parents_changed();
   virtual void transform_changed();
   virtual void transform_changed();
 
 
 private:
 private:
   CPT(TransformState) _sync;
   CPT(TransformState) _sync;
   bool _sync_disable;
   bool _sync_disable;
+  bool _sync_local;
 
 
   btPairCachingGhostObject *_ghost;
   btPairCachingGhostObject *_ghost;