2
0
Dave Schuyler 20 жил өмнө
parent
commit
18cc3f1b0f

+ 23 - 0
panda/src/physics/physicsObject.cxx

@@ -91,6 +91,29 @@ make_copy() const {
   return new PhysicsObject(*this);
 }
 
+////////////////////////////////////////////////////////////////////
+//    Function : add_impact
+//      Access : Public
+// Description : Adds an impulse and/or torque (i.e. an instantanious
+//               change in velocity) based on how well the offset and
+//               impulse align with the center of mass (aka position).
+//               If you wanted to immitate this function you could
+//               work out the impulse and torque and call add_impulse
+//               and add_torque respectively.
+////////////////////////////////////////////////////////////////////
+void PhysicsObject::
+add_impact(const LPoint3f &offset_from_center_of_mass,
+    const LVector3f &force) {
+  nassertv(!offset_from_center_of_mass.is_nan());
+  nassertv(!force.is_nan());
+  LRotationf torque;
+  LVector3f impulse;
+  torque = LRotationf::ident_quat(); // place holder
+  impulse = LVector3f::zero(); // place holder
+  add_torque(torque);
+  add_impulse(impulse);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function : get_lcs
 //       Access : Public