mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
local torque and local impulse
This commit is contained in:
parent
241942299a
commit
5a52512d8e
@ -109,6 +109,34 @@ set_velocity(float x, float y, float z) {
|
||||
_velocity.set(x, y, z);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : add_local_torque
|
||||
// Access : Public
|
||||
// Description : Adds an torque force (i.e. an instantanious change
|
||||
// in velocity). This is a quicker way to get the
|
||||
// angular velocity, add a vector to it and set that
|
||||
// value to be the new angular velocity.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void PhysicsObject::
|
||||
add_local_torque(const LRotationf &torque) {
|
||||
nassertv(!torque.is_nan());
|
||||
_rotation+=_orientation.xform(torque);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : add_local_impulse
|
||||
// Access : Public
|
||||
// Description : Adds an impulse force (i.e. an instantanious change
|
||||
// in velocity). This is a quicker way to get the
|
||||
// velocity, add a vector to it and set that value to
|
||||
// be the new velocity.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void PhysicsObject::
|
||||
add_local_impulse(const LVector3f &impulse) {
|
||||
nassertv(!impulse.is_nan());
|
||||
_velocity+=_orientation.xform(impulse);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : add_torque
|
||||
// Access : Public
|
||||
|
@ -91,6 +91,30 @@ make_copy() const {
|
||||
return new PhysicsObject(*this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function : add_local_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.
|
||||
// offset and force are in local coordinates.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PhysicsObject::
|
||||
add_local_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 : add_impact
|
||||
// Access : Public
|
||||
@ -100,6 +124,7 @@ make_copy() const {
|
||||
// If you wanted to immitate this function you could
|
||||
// work out the impulse and torque and call add_impulse
|
||||
// and add_torque respectively.
|
||||
// offset and force are in global (or parent) coordinates.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PhysicsObject::
|
||||
add_impact(const LPoint3f &offset_from_center_of_mass,
|
||||
|
@ -63,11 +63,18 @@ PUBLISHED:
|
||||
INLINE LVector3f get_velocity() const;
|
||||
INLINE LVector3f get_implicit_velocity() const;
|
||||
|
||||
// Global instantanious forces
|
||||
INLINE void add_torque(const LRotationf &torque);
|
||||
INLINE void add_impulse(const LVector3f &impulse);
|
||||
virtual void add_impact(
|
||||
const LPoint3f &offset_from_center_of_mass, const LVector3f &impulse);
|
||||
|
||||
// Local instantanious forces
|
||||
INLINE void add_local_torque(const LRotationf &torque);
|
||||
INLINE void add_local_impulse(const LVector3f &impulse);
|
||||
virtual void add_local_impact(
|
||||
const LPoint3f &offset_from_center_of_mass, const LVector3f &impulse);
|
||||
|
||||
INLINE void set_terminal_velocity(float tv);
|
||||
INLINE float get_terminal_velocity() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user