added viscosity

This commit is contained in:
Dave Schuyler 2003-07-25 22:02:18 +00:00
parent d362c5c9bb
commit ad4be177e2
3 changed files with 45 additions and 21 deletions

View File

@ -210,3 +210,24 @@ get_angular_force(int index) const {
nassertr(index >= 0 && index < (int)_angular_forces.size(), NULL);
return _angular_forces[index];
}
////////////////////////////////////////////////////////////////////
// Function : set_viscosity
// Access : Public
// Description : Set the local viscosity.
////////////////////////////////////////////////////////////////////
INLINE void Physical::
set_viscosity(float viscosity) {
_viscosity=viscosity;
}
////////////////////////////////////////////////////////////////////
// Function : get_viscosity
// Access : Public
// Description : Get the local viscosity.
////////////////////////////////////////////////////////////////////
INLINE float Physical::
get_viscosity() const {
//zzzzzzzzzzzzzzzz return max(_viscosity, get_physics_manager()->get_viscosity());
return _viscosity;
}

View File

@ -23,40 +23,39 @@
TypeHandle Physical::_type_handle;
// the idea here is that most physicals will NOT be collections of
// sets (i.e. particle systems and whatever else). Because of this,
// the default constructor, unless otherwise specified, will
// automatically allocate and initialize one PhysicalObject.
// this makes it easier for high-level work.
// pre-alloc is ONLY for multiple-object physicals, and if true,
// fills the physics_object vector with dead nodes, pre-allocating
// for the speed end of the speed-vs-overhead deal.
////////////////////////////////////////////////////////////////////
// Function : Physical
// Access : Public
// Description : Default Constructor
//
// The idea here is that most physicals will NOT
// be collections of sets (i.e. particle systems
// and whatever else). Because of this, the default
// constructor, unless otherwise specified, will
// automatically allocate and initialize one
// PhysicalObject. This makes it easier for
// high-level work.
//
// pre-alloc is ONLY for multiple-object physicals,
// and if true, fills the physics_object vector
// with dead nodes, pre-allocating for the speed
// end of the speed-vs-overhead deal.
////////////////////////////////////////////////////////////////////
Physical::
Physical(int ttl_objects, bool pre_alloc) {
Physical(int total_objects, bool pre_alloc) {
_viscosity=0.0;
_physical_node = (PhysicalNode *) NULL;
_physics_manager = (PhysicsManager *) NULL;
if (ttl_objects == 1) {
if (total_objects == 1) {
_phys_body = new PhysicsObject;
add_physics_object(_phys_body);
}
else {
int i;
} else {
_phys_body = (PhysicsObject *) NULL;
// allocate each object.
if (pre_alloc == true) {
PhysicsObject *po;
for (i = 0; i < ttl_objects; i++) {
po = new PhysicsObject;
for (int i = 0; i < total_objects; ++i) {
PhysicsObject *po = new PhysicsObject;
add_physics_object(po);
}
}

View File

@ -41,7 +41,7 @@ class PhysicsManager;
////////////////////////////////////////////////////////////////////
class EXPCL_PANDAPHYSICS Physical : public TypedReferenceCount {
PUBLISHED:
Physical(int ttl_objects = 1, bool pre_alloc = false);
Physical(int total_objects = 1, bool pre_alloc = false);
Physical(const Physical& copy);
virtual ~Physical();
@ -64,6 +64,9 @@ PUBLISHED:
INLINE PT(LinearForce) get_linear_force(int index) const;
INLINE int get_num_angular_forces() const;
INLINE PT(AngularForce) get_angular_force(int index) const;
INLINE void set_viscosity(float viscosity);
INLINE float get_viscosity() const;
virtual void output(ostream &out) const;
virtual void write_physics_objects(ostream &out, unsigned int indent=0) const;
@ -84,6 +87,7 @@ public:
friend class PhysicalNode;
protected:
float _viscosity;
// containers
PhysicsObjectVector _physics_objects;
LinearForceVector _linear_forces;