From 0ac40455aacdfd4bf445a7dafcc2320fcb76af31 Mon Sep 17 00:00:00 2001 From: Mike Goslin Date: Sat, 27 Jan 2001 00:47:00 +0000 Subject: [PATCH] *** empty log message *** --- direct/src/particles/ParticleTest.py | 10 ++++++++++ direct/src/particles/Particles.py | 2 +- direct/src/tkpanels/ParticlePanel.py | 4 ++-- .../src/particlesystem/particleSystemManager.I | 6 +++++- panda/src/physics/angularForce.cxx | 10 ++++++++++ panda/src/physics/angularForce.h | 3 ++- panda/src/physics/baseForce.h | 1 + panda/src/physics/linearForce.cxx | 9 +++++++++ panda/src/physics/linearForce.h | 2 ++ panda/src/physics/physicsManager.I | 17 ++++++++++++++--- 10 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 direct/src/particles/ParticleTest.py diff --git a/direct/src/particles/ParticleTest.py b/direct/src/particles/ParticleTest.py new file mode 100644 index 0000000000..0f24531fd7 --- /dev/null +++ b/direct/src/particles/ParticleTest.py @@ -0,0 +1,10 @@ +from DirectSessionGlobal import * +import ParticleEffect +pe = ParticleEffect.ParticleEffect('particle-fx') +pe.reparentTo(render) +pe.setPos(0.0, 5.0, 4.0) +import ParticlePanel +p = pe.particles[0] +ParticlePanel.ParticlePanel(pe, p) +base.enableParticles() +pe.enable() diff --git a/direct/src/particles/Particles.py b/direct/src/particles/Particles.py index 49b412cc7f..a8ba475fb9 100644 --- a/direct/src/particles/Particles.py +++ b/direct/src/particles/Particles.py @@ -64,7 +64,7 @@ class Particles(ParticleSystem.ParticleSystem): def enable(self): """enable(self)""" - physicsMgr.attachPhysical(self.node) + physicsMgr.attachPhysical(self) particleMgr.attachParticlesystem(self) def disable(self): diff --git a/direct/src/tkpanels/ParticlePanel.py b/direct/src/tkpanels/ParticlePanel.py index 0b5c6992cc..b620d2c9c7 100644 --- a/direct/src/tkpanels/ParticlePanel.py +++ b/direct/src/tkpanels/ParticlePanel.py @@ -658,9 +658,9 @@ class ParticlePanel(AppShell): def toggleParticleSystem(self): if self.systemActive.get(): - self.particleEffect.activate() + self.particleEffect.enable() else: - self.particleEffect.deactivate() + self.particleEffect.disable() return None ## SYSTEM PAGE ## diff --git a/panda/src/particlesystem/particleSystemManager.I b/panda/src/particlesystem/particleSystemManager.I index 51731dd7b5..28e8aee689 100644 --- a/panda/src/particlesystem/particleSystemManager.I +++ b/panda/src/particlesystem/particleSystemManager.I @@ -31,7 +31,11 @@ get_frame_stepping(void) const { INLINE void ParticleSystemManager:: attach_particlesystem(ParticleSystem *ps) { ps->_manager = this; - _ps_list.push_back(ps); + list< PT(ParticleSystem) >::iterator found; + PT(ParticleSystem) ptps = ps; + found = find(_ps_list.begin(), _ps_list.end(), ptps); + if (found == _ps_list.end()) + _ps_list.push_back(ps); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physics/angularForce.cxx b/panda/src/physics/angularForce.cxx index 8d066c8725..0d5ea4e72c 100644 --- a/panda/src/physics/angularForce.cxx +++ b/panda/src/physics/angularForce.cxx @@ -46,3 +46,13 @@ get_vector(const PhysicsObject *po) { LVector3f v = get_child_vector(po); return v; } + +//////////////////////////////////////////////////////////////////// +// Function : is_linear +// Access : public +// Description : access query +//////////////////////////////////////////////////////////////////// +bool AngularForce:: +is_linear(void) const { + return false; +} diff --git a/panda/src/physics/angularForce.h b/panda/src/physics/angularForce.h index 303fe0b913..1d16bae489 100644 --- a/panda/src/physics/angularForce.h +++ b/panda/src/physics/angularForce.h @@ -20,11 +20,12 @@ protected: AngularForce(void); AngularForce(const AngularForce ©); -public: +PUBLISHED: virtual ~AngularForce(void); virtual AngularForce *make_copy(void) const = 0; LVector3f get_vector(const PhysicsObject *po); + virtual bool is_linear(void) const; public: static TypeHandle get_class_type(void) { diff --git a/panda/src/physics/baseForce.h b/panda/src/physics/baseForce.h index 484b4fe40b..15fee20b71 100644 --- a/panda/src/physics/baseForce.h +++ b/panda/src/physics/baseForce.h @@ -35,6 +35,7 @@ public: INLINE bool get_active(void) const; INLINE void set_active(bool active); + virtual bool is_linear(void) const = 0; INLINE ForceNode *get_force_node(void) const; diff --git a/panda/src/physics/linearForce.cxx b/panda/src/physics/linearForce.cxx index 151a6213a7..9a00095d4d 100644 --- a/panda/src/physics/linearForce.cxx +++ b/panda/src/physics/linearForce.cxx @@ -67,3 +67,12 @@ get_vector(const PhysicsObject *po) { return child_vector; } + +//////////////////////////////////////////////////////////////////// +// Function : is_linear +// Access : Public +//////////////////////////////////////////////////////////////////// +bool LinearForce:: +is_linear(void) const { + return true; +} diff --git a/panda/src/physics/linearForce.h b/panda/src/physics/linearForce.h index 04b889f6f5..000bc1d9ac 100644 --- a/panda/src/physics/linearForce.h +++ b/panda/src/physics/linearForce.h @@ -43,6 +43,8 @@ PUBLISHED: virtual LinearForce *make_copy(void) = 0; + virtual bool is_linear(void) const; + public: static TypeHandle get_class_type(void) { return _type_handle; diff --git a/panda/src/physics/physicsManager.I b/panda/src/physics/physicsManager.I index 40217d106f..03d777dc4c 100644 --- a/panda/src/physics/physicsManager.I +++ b/panda/src/physics/physicsManager.I @@ -11,7 +11,10 @@ INLINE void PhysicsManager:: attach_physical(Physical *p) { p->_physics_manager = this; - _physicals.push_back(p); + vector< Physical * >::iterator found; + found = find(_physicals.begin(), _physicals.end(), p); + if (found == _physicals.end()) + _physicals.push_back(p); } //////////////////////////////////////////////////////////////////// @@ -21,7 +24,11 @@ attach_physical(Physical *p) { //////////////////////////////////////////////////////////////////// INLINE void PhysicsManager:: add_linear_force(LinearForce *f) { - _linear_forces.push_back(f); + vector< PT(LinearForce) >::iterator found; + PT(LinearForce) ptlf = f; + found = find(_linear_forces.begin(), _linear_forces.end(), ptlf); + if (found == _linear_forces.end()) + _linear_forces.push_back(f); } //////////////////////////////////////////////////////////////////// @@ -52,7 +59,11 @@ clear_linear_forces(void) { //////////////////////////////////////////////////////////////////// INLINE void PhysicsManager:: add_angular_force(AngularForce *f) { - _angular_forces.push_back(f); + vector< PT(AngularForce) >::iterator found; + PT(AngularForce) ptaf = f; + found = find(_angular_forces.begin(), _angular_forces.end(), ptaf); + if (found == _angular_forces.end()) + _angular_forces.push_back(f); } ////////////////////////////////////////////////////////////////////