upgrade particles to pgraph (broken at this point)

This commit is contained in:
David Rose 2002-03-22 01:48:52 +00:00
parent 2b729db8e8
commit 248cd826c8
23 changed files with 245 additions and 311 deletions

View File

@ -21,28 +21,11 @@
// Class : Public // Class : Public
// Description : Query the geomnode pointer // Description : Query the geomnode pointer
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE GeomNode *BaseParticleRenderer:: INLINE qpGeomNode *BaseParticleRenderer::
get_render_node(void) const { get_render_node(void) const {
return _render_node; return _render_node;
} }
////////////////////////////////////////////////////////////////////
// Function : disable_alpha
// Access : Private
// Description : kills the intermediate alpha node/arc
////////////////////////////////////////////////////////////////////
INLINE void BaseParticleRenderer::
disable_alpha(void) {
_alpha_node.clear();
if (_alpha_arc.is_null() == false) {
remove_arc(_alpha_arc);
_alpha_arc.clear();
}
_interface_node = _render_node;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function : set_alpha_mode // Function : set_alpha_mode
// Access : public // Access : public

View File

@ -16,10 +16,10 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include <pandabase.h> #include "pandabase.h"
#include <nodeRelation.h>
#include "baseParticleRenderer.h" #include "baseParticleRenderer.h"
#include "transparencyAttrib.h"
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function : BaseParticleRenderer // Function : BaseParticleRenderer
@ -28,9 +28,8 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
BaseParticleRenderer:: BaseParticleRenderer::
BaseParticleRenderer(ParticleRendererAlphaMode alpha_mode) : BaseParticleRenderer(ParticleRendererAlphaMode alpha_mode) :
_alpha_arc((RenderRelation *) NULL),
_alpha_mode(PR_NOT_INITIALIZED_YET) { _alpha_mode(PR_NOT_INITIALIZED_YET) {
_render_node = new GeomNode("BaseParticleRenderer render node"); _render_node = new qpGeomNode("BaseParticleRenderer render node");
_user_alpha = 1.0f; _user_alpha = 1.0f;
@ -44,9 +43,8 @@ BaseParticleRenderer(ParticleRendererAlphaMode alpha_mode) :
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
BaseParticleRenderer:: BaseParticleRenderer::
BaseParticleRenderer(const BaseParticleRenderer& copy) : BaseParticleRenderer(const BaseParticleRenderer& copy) :
_alpha_arc((RenderRelation *) NULL),
_alpha_mode(PR_ALPHA_NONE) { _alpha_mode(PR_ALPHA_NONE) {
_render_node = new GeomNode("BaseParticleRenderer render node"); _render_node = new qpGeomNode("BaseParticleRenderer render node");
_user_alpha = copy._user_alpha; _user_alpha = copy._user_alpha;
@ -60,8 +58,6 @@ BaseParticleRenderer(const BaseParticleRenderer& copy) :
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
BaseParticleRenderer:: BaseParticleRenderer::
~BaseParticleRenderer(void) { ~BaseParticleRenderer(void) {
if(_alpha_mode != PR_ALPHA_NONE)
remove_arc(_alpha_arc);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -72,14 +68,17 @@ BaseParticleRenderer::
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void BaseParticleRenderer:: void BaseParticleRenderer::
enable_alpha(void) { enable_alpha(void) {
_render_node->clear(); _render_state = RenderState::make(TransparencyAttrib::make(TransparencyAttrib::M_alpha));
}
_alpha_node = new GeomNode("BaseParticleRenderer alpha node"); ////////////////////////////////////////////////////////////////////
// Function : disable_alpha
_alpha_arc = new RenderRelation(_render_node, _alpha_node); // Access : Private
_alpha_arc->set_transition(new TransparencyTransition(TransparencyProperty::M_alpha)); // Description : kills the intermediate alpha node/arc
////////////////////////////////////////////////////////////////////
_interface_node = _alpha_node; void BaseParticleRenderer::
disable_alpha(void) {
_render_state = RenderState::make(TransparencyAttrib::make(TransparencyAttrib::M_none));
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -19,13 +19,11 @@
#ifndef BASEPARTICLERENDERER_H #ifndef BASEPARTICLERENDERER_H
#define BASEPARTICLERENDERER_H #define BASEPARTICLERENDERER_H
#include <pandabase.h> #include "pandabase.h"
#include <referenceCount.h> #include "referenceCount.h"
#include <physicsObject.h> #include "physicsObject.h"
#include <geomNode.h> #include "renderState.h"
#include <renderRelation.h> #include "qpgeomNode.h"
#include <nodeRelation.h>
#include <transparencyTransition.h>
#include "particleCommonFuncs.h" #include "particleCommonFuncs.h"
#include "baseParticle.h" #include "baseParticle.h"
@ -38,14 +36,7 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
class EXPCL_PANDAPHYSICS BaseParticleRenderer : public ReferenceCount { class EXPCL_PANDAPHYSICS BaseParticleRenderer : public ReferenceCount {
private: private:
PT(GeomNode) _render_node; PT(qpGeomNode) _render_node;
// children of this class don't know anything about alpha.
// they should just interact with _interface_node, and link geometry
// from/to that.
PT(GeomNode) _alpha_node;
PT(RenderRelation) _alpha_arc;
float _user_alpha; float _user_alpha;
@ -81,7 +72,7 @@ PUBLISHED:
virtual ~BaseParticleRenderer(void); virtual ~BaseParticleRenderer(void);
INLINE GeomNode *get_render_node(void) const; INLINE qpGeomNode *get_render_node(void) const;
INLINE void set_alpha_mode(ParticleRendererAlphaMode am); INLINE void set_alpha_mode(ParticleRendererAlphaMode am);
INLINE ParticleRendererAlphaMode get_alpha_mode(void) const; INLINE ParticleRendererAlphaMode get_alpha_mode(void) const;
@ -90,8 +81,6 @@ PUBLISHED:
INLINE float get_user_alpha(void) const; INLINE float get_user_alpha(void) const;
protected: protected:
GeomNode *_interface_node;
ParticleRendererAlphaMode _alpha_mode; ParticleRendererAlphaMode _alpha_mode;
BaseParticleRenderer(ParticleRendererAlphaMode alpha_decay = PR_ALPHA_NONE); BaseParticleRenderer(ParticleRendererAlphaMode alpha_decay = PR_ALPHA_NONE);
@ -100,12 +89,14 @@ protected:
void update_alpha_mode(ParticleRendererAlphaMode am); void update_alpha_mode(ParticleRendererAlphaMode am);
void enable_alpha(void); void enable_alpha(void);
INLINE void disable_alpha(void); void disable_alpha(void);
INLINE float get_cur_alpha(BaseParticle* bp); INLINE float get_cur_alpha(BaseParticle* bp);
virtual void resize_pool(int new_size) = 0; virtual void resize_pool(int new_size) = 0;
CPT(RenderState) _render_state;
public: public:
virtual BaseParticleRenderer *make_copy(void) = 0; virtual BaseParticleRenderer *make_copy(void) = 0;

View File

@ -21,13 +21,13 @@
// Access : public // Access : public
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// we're forcing a pool resize to remove every arc in the vector. // we're forcing a pool resize to remove every node in the vector.
// this is because arcs are reference-counted, and we have to // this is because nodes are reference-counted, and we have to
// explicitly remove them from the node they were previously // explicitly remove them from the node they were previously parented
// pointing at. // to.
INLINE void GeomParticleRenderer:: INLINE void GeomParticleRenderer::
set_geom_node(Node *node) { set_geom_node(PandaNode *node) {
_geom_node = node; _geom_node = node;
resize_pool(_pool_size); resize_pool(_pool_size);
} }
@ -37,22 +37,7 @@ set_geom_node(Node *node) {
// Access : public // Access : public
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE Node *GeomParticleRenderer:: INLINE PandaNode *GeomParticleRenderer::
get_geom_node(void) { get_geom_node(void) {
return _geom_node; return _geom_node;
} }
////////////////////////////////////////////////////////////////////
// Function : kill_arcs
// Access : private
////////////////////////////////////////////////////////////////////
INLINE void GeomParticleRenderer::
kill_arcs(void) {
pvector< PT(RenderRelation) >::iterator vec_iter = _arc_vector.begin();
for (; vec_iter != _arc_vector.end(); vec_iter++)
remove_arc(*vec_iter);
_arc_vector.erase(_arc_vector.begin(), _arc_vector.end());
}

View File

@ -19,8 +19,8 @@
#include "geomParticleRenderer.h" #include "geomParticleRenderer.h"
#include "baseParticle.h" #include "baseParticle.h"
#include <transformTransition.h> #include "transformState.h"
#include <colorTransition.h> #include "colorAttrib.h"
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function : GeomParticleRenderer // Function : GeomParticleRenderer
@ -29,13 +29,11 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
GeomParticleRenderer:: GeomParticleRenderer::
GeomParticleRenderer(ParticleRendererAlphaMode am, Node *geom_node) : GeomParticleRenderer(ParticleRendererAlphaMode am, PandaNode *geom_node) :
BaseParticleRenderer(am), _geom_node(geom_node), _pool_size(0) { BaseParticleRenderer(am), _geom_node(geom_node), _pool_size(0) {
_dead_particle_parent_node = new Node;
if (_geom_node.is_null()) if (_geom_node.is_null())
_geom_node = _dead_particle_parent_node; _geom_node = new PandaNode("empty");
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -47,9 +45,6 @@ GeomParticleRenderer(ParticleRendererAlphaMode am, Node *geom_node) :
GeomParticleRenderer:: GeomParticleRenderer::
GeomParticleRenderer(const GeomParticleRenderer& copy) : GeomParticleRenderer(const GeomParticleRenderer& copy) :
BaseParticleRenderer(copy), _pool_size(0) { BaseParticleRenderer(copy), _pool_size(0) {
_dead_particle_parent_node = new Node;
_geom_node = copy._geom_node; _geom_node = copy._geom_node;
} }
@ -61,7 +56,7 @@ GeomParticleRenderer(const GeomParticleRenderer& copy) :
GeomParticleRenderer:: GeomParticleRenderer::
~GeomParticleRenderer(void) { ~GeomParticleRenderer(void) {
kill_arcs(); kill_nodes();
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -93,21 +88,39 @@ init_geoms(void) {
void GeomParticleRenderer:: void GeomParticleRenderer::
resize_pool(int new_size) { resize_pool(int new_size) {
kill_arcs(); kill_nodes();
// now repopulate the vector // now repopulate the vector with a bunch of NULLS, representing
// potential instances of the _geom_node.
int i; int i;
RenderRelation *rr;
for (i = 0; i < new_size; i++) { for (i = 0; i < new_size; i++) {
rr = new RenderRelation(_dead_particle_parent_node, _geom_node); _node_vector.push_back(NULL);
_arc_vector.push_back(rr);
} }
_pool_size = new_size; _pool_size = new_size;
} }
////////////////////////////////////////////////////////////////////
// Function : kill_nodes
// Access : private
////////////////////////////////////////////////////////////////////
INLINE void GeomParticleRenderer::
kill_nodes(void) {
pvector< PT(PandaNode) >::iterator vec_iter = _node_vector.begin();
PandaNode *render_node = get_render_node();
for (; vec_iter != _node_vector.end(); vec_iter++) {
PandaNode *node = *vec_iter;
if (node != (PandaNode *)NULL) {
render_node->remove_child(node);
}
}
_node_vector.erase(_node_vector.begin(), _node_vector.end());
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function : birth_particle // Function : birth_particle
// Access : Private, virtual // Access : Private, virtual
@ -116,7 +129,11 @@ resize_pool(int new_size) {
void GeomParticleRenderer:: void GeomParticleRenderer::
birth_particle(int index) { birth_particle(int index) {
_arc_vector[index]->change_parent(_interface_node); nassertv(_node_vector[index] == (PandaNode *)NULL);
PandaNode *node = new PandaNode("");
get_render_node()->add_child(node);
node->add_child(_geom_node);
_node_vector[index] = node;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -127,7 +144,8 @@ birth_particle(int index) {
void GeomParticleRenderer:: void GeomParticleRenderer::
kill_particle(int index) { kill_particle(int index) {
_arc_vector[index]->change_parent(_dead_particle_parent_node); get_render_node()->remove_child(_node_vector[index]);
_node_vector[index] = (PandaNode *)NULL;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -142,41 +160,39 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
LPoint3f pos; LPoint3f pos;
int i, remaining_particles = ttl_particles; int i, remaining_particles = ttl_particles;
pvector< PT(RenderRelation) >::iterator cur_arc_iter = _arc_vector.begin(); pvector< PT(PandaNode) >::iterator cur_node_iter = _node_vector.begin();
// run through the particle vector // run through the particle vector
for (i = 0; i < (int)po_vector.size(); i++) { for (i = 0; i < (int)po_vector.size(); i++) {
RenderRelation *cur_arc; PandaNode *cur_node;
cur_particle = (BaseParticle *) po_vector[i].p(); cur_particle = (BaseParticle *) po_vector[i].p();
cur_arc = *cur_arc_iter; cur_node = *cur_node_iter;
if (cur_particle->get_alive() == true) { if (cur_particle->get_alive() == true) {
// living particle // living particle
pos = cur_particle->get_position(); pos = cur_particle->get_position();
PT(TransformTransition) xform; cur_node->set_state(_render_state);
PT(ColorTransition) alpha;
xform = new TransformTransition(LMatrix4f::translate_mat(pos));
if ((_alpha_mode != PR_ALPHA_NONE)) { if ((_alpha_mode != PR_ALPHA_NONE)) {
float alpha_scalar; float alpha_scalar;
if(_alpha_mode == PR_ALPHA_USER) { if(_alpha_mode == PR_ALPHA_USER) {
alpha_scalar=get_user_alpha(); alpha_scalar=get_user_alpha();
} else { } else {
alpha_scalar = cur_particle->get_parameterized_age(); alpha_scalar = cur_particle->get_parameterized_age();
if (_alpha_mode == PR_ALPHA_OUT) if (_alpha_mode == PR_ALPHA_OUT)
alpha_scalar = 1.0f - alpha_scalar; alpha_scalar = 1.0f - alpha_scalar;
} }
alpha = new ColorTransition(1.0f, 1.0f, 1.0f, alpha_scalar); cur_node->set_attrib(ColorAttrib::make_flat
cur_arc->set_transition(alpha); (Colorf(1.0f, 1.0f, 1.0f, alpha_scalar)));
} }
cur_arc->set_transition(xform); cur_node->set_transform(TransformState::make_pos(pos));
// maybe get out early if possible. // maybe get out early if possible.
@ -186,6 +202,6 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
break; break;
} }
cur_arc_iter++; cur_node_iter++;
} }
} }

View File

@ -32,15 +32,12 @@
class EXPCL_PANDAPHYSICS GeomParticleRenderer : public BaseParticleRenderer { class EXPCL_PANDAPHYSICS GeomParticleRenderer : public BaseParticleRenderer {
private: private:
PT(Node) _geom_node; PT(PandaNode) _geom_node;
PT(Node) _dead_particle_parent_node;
pvector< PT(RenderRelation) > _arc_vector; pvector< PT(PandaNode) > _node_vector;
int _pool_size; int _pool_size;
INLINE void kill_arcs(void);
// geomparticlerenderer takes advantage of the birth/death functions // geomparticlerenderer takes advantage of the birth/death functions
virtual void birth_particle(int index); virtual void birth_particle(int index);
@ -51,15 +48,16 @@ private:
int ttl_particles); int ttl_particles);
virtual void resize_pool(int new_size); virtual void resize_pool(int new_size);
void kill_nodes(void);
PUBLISHED: PUBLISHED:
GeomParticleRenderer(ParticleRendererAlphaMode am = PR_ALPHA_NONE, GeomParticleRenderer(ParticleRendererAlphaMode am = PR_ALPHA_NONE,
Node *geom_node = (Node *) NULL); PandaNode *geom_node = (PandaNode *) NULL);
GeomParticleRenderer(const GeomParticleRenderer& copy); GeomParticleRenderer(const GeomParticleRenderer& copy);
virtual ~GeomParticleRenderer(void); virtual ~GeomParticleRenderer(void);
INLINE void set_geom_node(Node *node); INLINE void set_geom_node(PandaNode *node);
INLINE Node *get_geom_node(void); INLINE PandaNode *get_geom_node(void);
virtual BaseParticleRenderer *make_copy(void); virtual BaseParticleRenderer *make_copy(void);
}; };

View File

@ -138,8 +138,9 @@ void LineParticleRenderer::
init_geoms(void) { init_geoms(void) {
_line_primitive->set_num_prims(0); _line_primitive->set_num_prims(0);
_interface_node->clear(); qpGeomNode *render_node = get_render_node();
_interface_node->add_geom(_line_primitive); render_node->remove_all_geoms();
render_node->add_geom(_line_primitive, _render_state);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -237,5 +238,5 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
LPoint3f aabb_center = (_aabb_min + _aabb_max) * 0.5f; LPoint3f aabb_center = (_aabb_min + _aabb_max) * 0.5f;
float radius = (aabb_center - _aabb_min).length(); float radius = (aabb_center - _aabb_min).length();
_interface_node->set_bound(BoundingSphere(aabb_center, radius)); get_render_node()->set_bound(BoundingSphere(aabb_center, radius));
} }

View File

@ -84,10 +84,11 @@ set_renderer(BaseParticleRenderer *r) {
_renderer = r; _renderer = r;
_renderer->resize_pool(_particle_pool_size); _renderer->resize_pool(_particle_pool_size);
if (_render_arc.is_null() == false) if (!_render_node.is_null())
remove_arc(_render_arc); _render_parent->remove_child(_render_node);
_render_arc = new RenderRelation(_render_parent, r->get_render_node()); _render_node = _renderer->get_render_node();
_render_parent->add_child(_render_node);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -180,7 +181,7 @@ set_system_age(float age) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE void ParticleSystem:: INLINE void ParticleSystem::
set_spawn_render_node(Node *node) { set_spawn_render_node(PandaNode *node) {
_spawn_render_node = node; _spawn_render_node = node;
} }
@ -190,14 +191,13 @@ set_spawn_render_node(Node *node) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE void ParticleSystem:: INLINE void ParticleSystem::
set_render_parent(Node *node) { set_render_parent(PandaNode *node) {
if (_render_arc.is_null() == false) { if (!_render_node.is_null())
remove_arc(_render_arc); _render_parent->remove_child(_render_node);
}
_render_parent = node; _render_parent = node;
_render_arc = new RenderRelation(_render_parent, _render_node = _renderer->get_render_node();
_renderer->get_render_node()); _render_parent->add_child(_render_node);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -372,7 +372,7 @@ get_i_was_spawned_flag(void) const {
// Function : get_spawn_render_node // Function : get_spawn_render_node
// Access : public // Access : public
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE Node *ParticleSystem:: INLINE PandaNode *ParticleSystem::
get_spawn_render_node(void) const { get_spawn_render_node(void) const {
return _spawn_render_node; return _spawn_render_node;
} }
@ -381,7 +381,7 @@ get_spawn_render_node(void) const {
// Function : get_render_parent // Function : get_render_parent
// Access : public // Access : public
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE Node *ParticleSystem:: INLINE PandaNode *ParticleSystem::
get_render_parent(void) const { get_render_parent(void) const {
return _render_parent; return _render_parent;
} }

View File

@ -18,15 +18,14 @@
#include <stdlib.h> #include <stdlib.h>
#include <luse.h> #include "luse.h"
#include <lmat_ops.h> #include "lmat_ops.h"
#include <get_rel_pos.h> #include "clockObject.h"
#include <clockObject.h> #include "physicsManager.h"
#include <nodeRelation.h> #include "physicalNode.h"
#include <transformTransition.h> #include "nearly_zero.h"
#include <physicsManager.h> #include "transformState.h"
#include <physicalNode.h> #include "qpnodePath.h"
#include <nearly_zero.h>
#include "config_particlesystem.h" #include "config_particlesystem.h"
#include "particleSystem.h" #include "particleSystem.h"
@ -63,8 +62,8 @@ ParticleSystem(int pool_size) :
// set_emitter(), etc...) forces them to set themselves up for the // set_emitter(), etc...) forces them to set themselves up for the
// system, keeping the pool sizes consistent. // system, keeping the pool sizes consistent.
_render_arc.clear(); _render_node.clear();
_render_parent = new NamedNode("ParticleSystem default render parent"); _render_parent = new PandaNode("ParticleSystem default render parent");
set_emitter(new SphereSurfaceEmitter); set_emitter(new SphereSurfaceEmitter);
@ -100,9 +99,9 @@ ParticleSystem(const ParticleSystem& copy) :
_renderer = copy._renderer->make_copy(); _renderer = copy._renderer->make_copy();
_factory = copy._factory; _factory = copy._factory;
_render_arc = copy._render_arc;
_render_parent = copy._render_parent; _render_parent = copy._render_parent;
_render_node = _renderer->get_render_node();
_render_parent->add_child(_render_node);
_tics_since_birth = _birth_rate; _tics_since_birth = _birth_rate;
_system_lifespan = copy._system_lifespan; _system_lifespan = copy._system_lifespan;
@ -120,15 +119,12 @@ ParticleSystem::
~ParticleSystem(void) { ~ParticleSystem(void) {
set_pool_size(0); set_pool_size(0);
if (_template_system_flag == false) { if (!_template_system_flag) {
_renderer.clear(); _renderer.clear();
if (_render_arc.is_null() == false) if (!_render_node.is_null())
remove_arc(_render_arc); _render_parent->remove_child(_render_node);
} }
if (_i_was_spawned_flag == true)
remove_arc(_physical_node_arc);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -174,14 +170,15 @@ birth_particle(void) {
// get the location of the new particle. // get the location of the new particle.
LPoint3f new_pos, world_pos; LPoint3f new_pos, world_pos;
LVector3f new_vel; LVector3f new_vel;
LMatrix4f birth_to_render_xform; qpGeomNode *render_node;
GeomNode *render_node;
_emitter->generate(new_pos, new_vel); _emitter->generate(new_pos, new_vel);
render_node = _renderer->get_render_node(); render_node = _renderer->get_render_node();
// go from birth space to render space // go from birth space to render space
get_rel_mat(get_physical_node(), render_node, birth_to_render_xform); qpNodePath physical_np(get_physical_node());
qpNodePath render_np(render_node);
const LMatrix4f &birth_to_render_xform = physical_np.get_mat(render_np);
world_pos = new_pos * birth_to_render_xform; world_pos = new_pos * birth_to_render_xform;
// cout << "New particle at " << world_pos << endl; // cout << "New particle at " << world_pos << endl;
@ -240,17 +237,14 @@ spawn_child_system(BaseParticle *bp) {
return; return;
} }
if (this_pn->get_num_parents(RenderRelation::get_class_type()) == 0) { if (this_pn->get_num_parents() == 0) {
physics_cat.error() << "ParticleSystem::spawn_child_system: " physics_cat.error() << "ParticleSystem::spawn_child_system: "
<< "PhysicalNode this system is contained in " << "PhysicalNode this system is contained in "
<< "has no parent, aborting." << endl; << "has no parent, aborting." << endl;
return; return;
} }
NodeRelation *parent_relation = PandaNode *parent = this_pn->get_parent(0);
this_pn->get_parent(RenderRelation::get_class_type(), 0);
Node *parent = parent_relation->get_parent();
// handle the spawn templates // handle the spawn templates
int new_ps_index = rand() % _spawn_templates.size(); int new_ps_index = rand() % _spawn_templates.size();
@ -262,25 +256,27 @@ spawn_child_system(BaseParticle *bp) {
// first, set up the render node info. // first, set up the render node info.
new_ps->_render_parent = _spawn_render_node; new_ps->_render_parent = _spawn_render_node;
new_ps->_render_arc = new RenderRelation(new_ps->_render_parent, new_ps->_render_node = new_ps->_renderer->get_render_node();
new_ps->_renderer->get_render_node()); new_ps->_render_parent->add_child(new_ps->_render_node);
// now set up the new system's PhysicalNode. // now set up the new system's PhysicalNode.
PT(PhysicalNode) new_pn = new PhysicalNode; PT(PhysicalNode) new_pn = new PhysicalNode("new_pn");
new_pn->add_physical(new_ps); new_pn->add_physical(new_ps);
// the arc from the parent to the new child has to represent the // the transform on the new child has to represent the transform
// transform from the current system up to its parent, and then // from the current system up to its parent, and then subsequently
// subsequently down to the new child. // down to the new child.
PT(RenderRelation) rr = new RenderRelation(parent, new_pn); parent->add_child(new_pn);
LMatrix4f old_system_to_parent_xform; qpNodePath parent_np(parent);
get_rel_mat(get_physical_node(), parent, old_system_to_parent_xform); qpNodePath physical_np(get_physical_node());
const LMatrix4f &old_system_to_parent_xform = physical_np.get_mat(parent_np);
LMatrix4f child_space_xform = old_system_to_parent_xform * LMatrix4f child_space_xform = old_system_to_parent_xform *
bp->get_lcs(); bp->get_lcs();
rr->set_transition(new TransformTransition(child_space_xform)); new_pn->set_transform(TransformState::make_mat(child_space_xform));
// tack the new system onto the managers // tack the new system onto the managers
_manager->attach_particlesystem(new_ps); _manager->attach_particlesystem(new_ps);

View File

@ -25,12 +25,11 @@
#ifndef PARTICLESYSTEM_H #ifndef PARTICLESYSTEM_H
#define PARTICLESYSTEM_H #define PARTICLESYSTEM_H
#include <pandabase.h> #include "pandabase.h"
#include <pointerTo.h> #include "pointerTo.h"
#include <physical.h> #include "physical.h"
#include <node.h> #include "pandaNode.h"
#include <referenceCount.h> #include "referenceCount.h"
#include <renderRelation.h>
#include "pdeque.h" #include "pdeque.h"
@ -78,8 +77,8 @@ private:
// _render_parent is the ALREADY ALLOC'D node under which this // _render_parent is the ALREADY ALLOC'D node under which this
// system will render its particles. // system will render its particles.
PT(Node) _render_parent; PT(PandaNode) _render_parent;
PT(RenderRelation) _render_arc; PT(PandaNode) _render_node;
bool _active_system_flag; bool _active_system_flag;
bool _local_velocity_flag; bool _local_velocity_flag;
@ -88,15 +87,13 @@ private:
// information for systems that will spawn // information for systems that will spawn
bool _spawn_on_death_flag; bool _spawn_on_death_flag;
PT(Node) _spawn_render_node; PT(PandaNode) _spawn_render_node;
pvector< PT(ParticleSystem) > _spawn_templates; pvector< PT(ParticleSystem) > _spawn_templates;
void spawn_child_system(BaseParticle *bp); void spawn_child_system(BaseParticle *bp);
// information for spawned systems // information for spawned systems
bool _i_was_spawned_flag; bool _i_was_spawned_flag;
PT(RenderRelation) _physical_node_arc;
PUBLISHED: PUBLISHED:
// constructor/destructor // constructor/destructor
@ -116,9 +113,9 @@ PUBLISHED:
INLINE void set_system_age(float age); INLINE void set_system_age(float age);
INLINE void set_active_system_flag(bool a); INLINE void set_active_system_flag(bool a);
INLINE void set_spawn_on_death_flag(bool sod); INLINE void set_spawn_on_death_flag(bool sod);
INLINE void set_spawn_render_node(Node *node); INLINE void set_spawn_render_node(PandaNode *node);
INLINE void set_template_system_flag(bool tsf); INLINE void set_template_system_flag(bool tsf);
INLINE void set_render_parent(Node *node); INLINE void set_render_parent(PandaNode *node);
INLINE void set_renderer(BaseParticleRenderer *r); INLINE void set_renderer(BaseParticleRenderer *r);
INLINE void set_emitter(BaseParticleEmitter *e); INLINE void set_emitter(BaseParticleEmitter *e);
INLINE void set_factory(BaseParticleFactory *f); INLINE void set_factory(BaseParticleFactory *f);
@ -133,10 +130,10 @@ PUBLISHED:
INLINE float get_system_age(void) const; INLINE float get_system_age(void) const;
INLINE bool get_active_system_flag(void) const; INLINE bool get_active_system_flag(void) const;
INLINE bool get_spawn_on_death_flag(void) const; INLINE bool get_spawn_on_death_flag(void) const;
INLINE Node *get_spawn_render_node(void) const; INLINE PandaNode *get_spawn_render_node(void) const;
INLINE bool get_i_was_spawned_flag(void) const; INLINE bool get_i_was_spawned_flag(void) const;
INLINE int get_living_particles(void) const; INLINE int get_living_particles(void) const;
INLINE Node *get_render_parent(void) const; INLINE PandaNode *get_render_parent(void) const;
INLINE BaseParticleRenderer *get_renderer(void) const; INLINE BaseParticleRenderer *get_renderer(void) const;
INLINE BaseParticleEmitter *get_emitter(void) const; INLINE BaseParticleEmitter *get_emitter(void) const;
INLINE BaseParticleFactory *get_factory(void) const; INLINE BaseParticleFactory *get_factory(void) const;

View File

@ -16,8 +16,9 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include <boundingSphere.h>
#include "pointParticleRenderer.h" #include "pointParticleRenderer.h"
#include "boundingSphere.h"
#include "qpgeomNode.h"
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function : PointParticleRenderer // Function : PointParticleRenderer
@ -115,8 +116,9 @@ init_geoms(void) {
_point_primitive->set_num_prims(0); _point_primitive->set_num_prims(0);
_point_primitive->set_size(_point_size); _point_primitive->set_size(_point_size);
_interface_node->clear(); qpGeomNode *render_node = get_render_node();
_interface_node->add_geom(_point_primitive); render_node->remove_all_geoms();
render_node->add_geom(_point_primitive, _render_state);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -276,5 +278,5 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
LPoint3f aabb_center = _aabb_min + ((_aabb_max - _aabb_min) * 0.5f); LPoint3f aabb_center = _aabb_min + ((_aabb_max - _aabb_min) * 0.5f);
float radius = (aabb_center - _aabb_min).length(); float radius = (aabb_center - _aabb_min).length();
_interface_node->set_bound(BoundingSphere(aabb_center, radius)); get_render_node()->set_bound(BoundingSphere(aabb_center, radius));
} }

View File

@ -18,7 +18,8 @@
#include "sparkleParticleRenderer.h" #include "sparkleParticleRenderer.h"
#include <boundingSphere.h> #include "boundingSphere.h"
#include "qpgeomNode.h"
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function : SparkleParticleRenderer // Function : SparkleParticleRenderer
@ -146,8 +147,9 @@ void SparkleParticleRenderer::
init_geoms(void) { init_geoms(void) {
_line_primitive->set_num_prims(0); _line_primitive->set_num_prims(0);
_interface_node->clear(); qpGeomNode *render_node = get_render_node();
_interface_node->add_geom(_line_primitive); render_node->remove_all_geoms();
render_node->add_geom(_line_primitive, _render_state);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -266,5 +268,5 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
LPoint3f aabb_center = _aabb_min + ((_aabb_max - _aabb_min) * 0.5f); LPoint3f aabb_center = _aabb_min + ((_aabb_max - _aabb_min) * 0.5f);
float radius = (aabb_center - _aabb_min).length(); float radius = (aabb_center - _aabb_min).length();
_interface_node->set_bound(BoundingSphere(aabb_center, radius)); get_render_node()->set_bound(BoundingSphere(aabb_center, radius));
} }

View File

@ -16,12 +16,9 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include <boundingSphere.h> #include "boundingSphere.h"
#include <geom.h> #include "geom.h"
#include <nodePath.h> #include "qpnodePath.h"
#include <nodeTransitionWrapper.h>
#include <textureTransition.h>
#include <wrt.h>
#include "spriteParticleRenderer.h" #include "spriteParticleRenderer.h"
@ -99,36 +96,24 @@ make_copy(void) {
// Texture and UV range from the GeomNode. // Texture and UV range from the GeomNode.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void SpriteParticleRenderer:: void SpriteParticleRenderer::
set_from_node(const NodePath &node_path) { set_from_node(const qpNodePath &node_path) {
nassertv(!node_path.is_empty()); nassertv(!node_path.is_empty());
// The bottom node must be a GeomNode. If it is not, find the first // The bottom node must be a GeomNode. If it is not, find the first
// GeomNode beneath it. // GeomNode beneath it.
NodePath geom_node_path = node_path; qpNodePath geom_node_path = node_path;
if (!geom_node_path.node()->is_of_type(GeomNode::get_class_type())) { if (!geom_node_path.node()->is_geom_node()) {
geom_node_path = node_path.find("**/+GeomNode"); geom_node_path = node_path.find("**/+GeomNode");
if (geom_node_path.empty()) { if (geom_node_path.is_empty()) {
particlesystem_cat.error() particlesystem_cat.error()
<< node_path << " does not contain a GeomNode.\n"; << node_path << " does not contain a GeomNode.\n";
return; return;
} }
} }
GeomNode *gnode = DCAST(GeomNode, geom_node_path.node()); qpGeomNode *gnode = DCAST(qpGeomNode, geom_node_path.node());
// Get the texture off the node. We use wrt() to determine the net // Get the texture off the node. We'll take just the first texture.
// texture that's applied, based on all the arcs from the root; not Texture *tex = geom_node_path.find_texture("*");
// just the bottom arc.
Texture *tex = (Texture *)NULL;
NodeTransitionWrapper ntw(TextureTransition::get_class_type());
wrt(gnode, geom_node_path.begin(), geom_node_path.end(),
(Node *)NULL, ntw, RenderRelation::get_class_type());
const TextureTransition *tt;
if (get_transition_into(tt, ntw)) {
if (tt->is_on()) {
tex = tt->get_texture();
}
}
if (tex == (Texture *)NULL) { if (tex == (Texture *)NULL) {
particlesystem_cat.error() particlesystem_cat.error()
@ -138,7 +123,7 @@ set_from_node(const NodePath &node_path) {
// Now examine the UV's of the first Geom within the GeomNode. // Now examine the UV's of the first Geom within the GeomNode.
nassertv(gnode->get_num_geoms() > 0); nassertv(gnode->get_num_geoms() > 0);
Geom *geom = DCAST(Geom, gnode->get_geom(0)); Geom *geom = gnode->get_geom(0);
PTA_TexCoordf texcoords; PTA_TexCoordf texcoords;
GeomBindType bind; GeomBindType bind;
@ -248,8 +233,9 @@ void SpriteParticleRenderer::
init_geoms(void) { init_geoms(void) {
_sprite_primitive->set_num_prims(0); _sprite_primitive->set_num_prims(0);
_interface_node->clear(); qpGeomNode *render_node = get_render_node();
_interface_node->add_geom(_sprite_primitive); render_node->remove_all_geoms();
render_node->add_geom(_sprite_primitive, _render_state);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -388,5 +374,5 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
LPoint3f aabb_center = _aabb_min + ((_aabb_max - _aabb_min) * 0.5f); LPoint3f aabb_center = _aabb_min + ((_aabb_max - _aabb_min) * 0.5f);
float radius = (aabb_center - _aabb_min).length(); float radius = (aabb_center - _aabb_min).length();
_interface_node->set_bound(BoundingSphere(aabb_center, radius)); get_render_node()->set_bound(BoundingSphere(aabb_center, radius));
} }

View File

@ -19,18 +19,18 @@
#ifndef SPRITEPARTICLERENDERER_H #ifndef SPRITEPARTICLERENDERER_H
#define SPRITEPARTICLERENDERER_H #define SPRITEPARTICLERENDERER_H
#include <pandabase.h> #include "pandabase.h"
#include <texture.h> #include "texture.h"
#include <pointerTo.h> #include "pointerTo.h"
#include <pointerToArray.h> #include "pointerToArray.h"
#include <pta_float.h> #include "pta_float.h"
#include <geom.h> #include "geom.h"
#include <geomSprite.h> #include "geomSprite.h"
#include "baseParticleRenderer.h" #include "baseParticleRenderer.h"
#include "baseParticle.h" #include "baseParticle.h"
class NodePath; class qpNodePath;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Class : SpriteParticleRenderer // Class : SpriteParticleRenderer
@ -88,7 +88,7 @@ PUBLISHED:
INLINE SourceType get_source_type() const; INLINE SourceType get_source_type() const;
void set_from_node(const NodePath &node_path); void set_from_node(const qpNodePath &node_path);
INLINE void set_texture(Texture *tex); INLINE void set_texture(Texture *tex);
INLINE void set_ll_uv(const TexCoordf &ll_uv); INLINE void set_ll_uv(const TexCoordf &ll_uv);

View File

@ -1463,7 +1463,7 @@ get_texture() const {
Texture *qpNodePath:: Texture *qpNodePath::
find_texture(const string &name) const { find_texture(const string &name) const {
GlobPattern glob(name); GlobPattern glob(name);
return r_find_texture(node(), RenderState::make_empty(), glob); return r_find_texture(node(), get_net_state(), glob);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -1475,7 +1475,7 @@ find_texture(const string &name) const {
TextureCollection qpNodePath:: TextureCollection qpNodePath::
find_all_textures() const { find_all_textures() const {
Textures textures; Textures textures;
r_find_all_textures(node(), RenderState::make_empty(), textures); r_find_all_textures(node(), get_net_state(), textures);
TextureCollection tc; TextureCollection tc;
Textures::iterator ti; Textures::iterator ti;
@ -1495,7 +1495,7 @@ find_all_textures() const {
TextureCollection qpNodePath:: TextureCollection qpNodePath::
find_all_textures(const string &name) const { find_all_textures(const string &name) const {
Textures textures; Textures textures;
r_find_all_textures(node(), RenderState::make_empty(), textures); r_find_all_textures(node(), get_net_state(), textures);
GlobPattern glob(name); GlobPattern glob(name);
@ -2919,8 +2919,6 @@ r_calc_tight_bounds(PandaNode *node, LPoint3f &min_point, LPoint3f &max_point,
Texture * qpNodePath:: Texture * qpNodePath::
r_find_texture(PandaNode *node, const RenderState *state, r_find_texture(PandaNode *node, const RenderState *state,
const GlobPattern &glob) const { const GlobPattern &glob) const {
CPT(RenderState) next_state = state->compose(node->get_state());
if (node->is_geom_node()) { if (node->is_geom_node()) {
qpGeomNode *gnode; qpGeomNode *gnode;
DCAST_INTO_R(gnode, node, NULL); DCAST_INTO_R(gnode, node, NULL);
@ -2928,7 +2926,7 @@ r_find_texture(PandaNode *node, const RenderState *state,
int num_geoms = gnode->get_num_geoms(); int num_geoms = gnode->get_num_geoms();
for (int i = 0; i < num_geoms; i++) { for (int i = 0; i < num_geoms; i++) {
CPT(RenderState) geom_state = CPT(RenderState) geom_state =
next_state->compose(gnode->get_geom_state(i)); state->compose(gnode->get_geom_state(i));
// Look for a TextureAttrib on the state. // Look for a TextureAttrib on the state.
const RenderAttrib *attrib = const RenderAttrib *attrib =
@ -2949,7 +2947,10 @@ r_find_texture(PandaNode *node, const RenderState *state,
PandaNode::Children cr = node->get_children(); PandaNode::Children cr = node->get_children();
int num_children = cr.get_num_children(); int num_children = cr.get_num_children();
for (int i = 0; i < num_children; i++) { for (int i = 0; i < num_children; i++) {
Texture *result = r_find_texture(cr.get_child(i), next_state, glob); PandaNode *child = cr.get_child(i);
CPT(RenderState) next_state = state->compose(child->get_state());
Texture *result = r_find_texture(child, next_state, glob);
if (result != (Texture *)NULL) { if (result != (Texture *)NULL) {
return result; return result;
} }
@ -2966,8 +2967,6 @@ r_find_texture(PandaNode *node, const RenderState *state,
void qpNodePath:: void qpNodePath::
r_find_all_textures(PandaNode *node, const RenderState *state, r_find_all_textures(PandaNode *node, const RenderState *state,
qpNodePath::Textures &textures) const { qpNodePath::Textures &textures) const {
CPT(RenderState) next_state = state->compose(node->get_state());
if (node->is_geom_node()) { if (node->is_geom_node()) {
qpGeomNode *gnode; qpGeomNode *gnode;
DCAST_INTO_V(gnode, node); DCAST_INTO_V(gnode, node);
@ -2975,7 +2974,7 @@ r_find_all_textures(PandaNode *node, const RenderState *state,
int num_geoms = gnode->get_num_geoms(); int num_geoms = gnode->get_num_geoms();
for (int i = 0; i < num_geoms; i++) { for (int i = 0; i < num_geoms; i++) {
CPT(RenderState) geom_state = CPT(RenderState) geom_state =
next_state->compose(gnode->get_geom_state(i)); state->compose(gnode->get_geom_state(i));
// Look for a TextureAttrib on the state. // Look for a TextureAttrib on the state.
const RenderAttrib *attrib = const RenderAttrib *attrib =
@ -2994,7 +2993,9 @@ r_find_all_textures(PandaNode *node, const RenderState *state,
PandaNode::Children cr = node->get_children(); PandaNode::Children cr = node->get_children();
int num_children = cr.get_num_children(); int num_children = cr.get_num_children();
for (int i = 0; i < num_children; i++) { for (int i = 0; i < num_children; i++) {
r_find_all_textures(cr.get_child(i), next_state, textures); PandaNode *child = cr.get_child(i);
CPT(RenderState) next_state = state->compose(child->get_state());
r_find_all_textures(child, next_state, textures);
} }
} }

View File

@ -21,8 +21,6 @@
#include "physicalNode.h" #include "physicalNode.h"
#include "config_physics.h" #include "config_physics.h"
#include <get_rel_pos.h>
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function : AngularEulerIntegrator // Function : AngularEulerIntegrator
// Access : Public // Access : Public

View File

@ -19,8 +19,7 @@
#include "baseIntegrator.h" #include "baseIntegrator.h"
#include "physicalNode.h" #include "physicalNode.h"
#include "forceNode.h" #include "forceNode.h"
#include "qpnodePath.h"
#include <get_rel_pos.h>
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function : BaseIntegrator // Function : BaseIntegrator
@ -62,20 +61,21 @@ precompute_linear_matrices(Physical *physical,
int local_force_vec_size = physical->get_linear_forces().size(); int local_force_vec_size = physical->get_linear_forces().size();
int i; int i;
LMatrix4f current_xform;
ForceNode *force_node; ForceNode *force_node;
// prepare the vector // prepare the vector
_precomputed_linear_matrices.clear(); _precomputed_linear_matrices.clear();
_precomputed_linear_matrices.reserve(global_force_vec_size + local_force_vec_size); _precomputed_linear_matrices.reserve(global_force_vec_size + local_force_vec_size);
qpNodePath physical_np(physical_node);
// tally the global xforms // tally the global xforms
for (i = 0; i < global_force_vec_size; i++) { for (i = 0; i < global_force_vec_size; i++) {
force_node = forces[i]->get_force_node(); force_node = forces[i]->get_force_node();
nassertv(force_node != (ForceNode *) NULL); nassertv(force_node != (ForceNode *) NULL);
get_rel_mat(physical_node, force_node, current_xform); qpNodePath force_np(force_node);
_precomputed_linear_matrices.push_back(current_xform); _precomputed_linear_matrices.push_back(physical_np.get_mat(force_node));
} }
const pvector< PT(LinearForce) > &force_vector = const pvector< PT(LinearForce) > &force_vector =
@ -86,8 +86,8 @@ precompute_linear_matrices(Physical *physical,
force_node = force_vector[i]->get_force_node(); force_node = force_vector[i]->get_force_node();
nassertv(force_node != (ForceNode *) NULL); nassertv(force_node != (ForceNode *) NULL);
get_rel_mat(physical_node, force_node, current_xform); qpNodePath force_np(force_node);
_precomputed_linear_matrices.push_back(current_xform); _precomputed_linear_matrices.push_back(physical_np.get_mat(force_node));
} }
} }
@ -113,20 +113,21 @@ precompute_angular_matrices(Physical *physical,
int local_force_vec_size = physical->get_angular_forces().size(); int local_force_vec_size = physical->get_angular_forces().size();
int i; int i;
LMatrix4f current_xform;
ForceNode *force_node; ForceNode *force_node;
// prepare the vector // prepare the vector
_precomputed_angular_matrices.clear(); _precomputed_angular_matrices.clear();
_precomputed_angular_matrices.reserve(global_force_vec_size + local_force_vec_size); _precomputed_angular_matrices.reserve(global_force_vec_size + local_force_vec_size);
qpNodePath physical_np(physical_node);
// tally the global xforms // tally the global xforms
for (i = 0; i < global_force_vec_size; i++) { for (i = 0; i < global_force_vec_size; i++) {
force_node = forces[i]->get_force_node(); force_node = forces[i]->get_force_node();
nassertv(force_node != (ForceNode *) NULL); nassertv(force_node != (ForceNode *) NULL);
get_rel_mat(physical_node, force_node, current_xform); qpNodePath force_np(force_node);
_precomputed_angular_matrices.push_back(current_xform); _precomputed_angular_matrices.push_back(physical_np.get_mat(force_node));
} }
const pvector< PT(AngularForce) > &force_vector = const pvector< PT(AngularForce) > &force_vector =
@ -137,7 +138,7 @@ precompute_angular_matrices(Physical *physical,
force_node = force_vector[i]->get_force_node(); force_node = force_vector[i]->get_force_node();
nassertv(force_node != (ForceNode *) NULL); nassertv(force_node != (ForceNode *) NULL);
get_rel_mat(physical_node, force_node, current_xform); qpNodePath force_np(force_node);
_precomputed_angular_matrices.push_back(current_xform); _precomputed_angular_matrices.push_back(physical_np.get_mat(force_node));
} }
} }

View File

@ -28,17 +28,18 @@ TypeHandle ForceNode::_type_handle;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
ForceNode:: ForceNode::
ForceNode(const string &name) : ForceNode(const string &name) :
NamedNode(name) { PandaNode(name)
{
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function : ForceNode // Function : ForceNode
// Access : public // Access : protected
// Description : copy constructor // Description : copy constructor
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
ForceNode:: ForceNode::
ForceNode(const ForceNode &copy) : ForceNode(const ForceNode &copy) :
NamedNode(copy), _forces(copy._forces) { PandaNode(copy), _forces(copy._forces) {
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -50,24 +51,12 @@ ForceNode::
~ForceNode(void) { ~ForceNode(void) {
} }
////////////////////////////////////////////////////////////////////
// Function : operator =
// Access : public
// Description : assignment operator
////////////////////////////////////////////////////////////////////
ForceNode &ForceNode::
operator =(const ForceNode &copy) {
NamedNode::operator =(copy);
_forces = copy._forces;
return *this;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function : make_copy // Function : make_copy
// Access : public, virtual // Access : public, virtual
// Description : dynamic child copy // Description : dynamic child copy
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
Node *ForceNode:: PandaNode *ForceNode::
make_copy(void) const { make_copy(void) const {
return new ForceNode(*this); return new ForceNode(*this);
} }

View File

@ -19,7 +19,7 @@
#ifndef FORCENODE_H #ifndef FORCENODE_H
#define FORCENODE_H #define FORCENODE_H
#include <namedNode.h> #include "pandaNode.h"
#include "pvector.h" #include "pvector.h"
#include "baseForce.h" #include "baseForce.h"
@ -31,20 +31,22 @@
// An example of this would be simulating gravity // An example of this would be simulating gravity
// in a rotating space station. or something. // in a rotating space station. or something.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
class EXPCL_PANDAPHYSICS ForceNode : public NamedNode { class EXPCL_PANDAPHYSICS ForceNode : public PandaNode {
private: private:
pvector< PT(BaseForce) > _forces; pvector< PT(BaseForce) > _forces;
PUBLISHED: PUBLISHED:
ForceNode(const string &name = ""); ForceNode(const string &name);
protected:
ForceNode(const ForceNode &copy); ForceNode(const ForceNode &copy);
public:
virtual ~ForceNode(void); virtual ~ForceNode(void);
ForceNode &operator =(const ForceNode &copy);
virtual bool safe_to_flatten(void) const { return false; } virtual bool safe_to_flatten(void) const { return false; }
virtual Node *make_copy(void) const; virtual PandaNode *make_copy(void) const;
PUBLISHED:
INLINE void clear(void); INLINE void clear(void);
INLINE BaseForce *get_force(int index) const; INLINE BaseForce *get_force(int index) const;
INLINE int get_num_forces(void) const; INLINE int get_num_forces(void) const;
@ -59,9 +61,9 @@ public:
return _type_handle; return _type_handle;
} }
static void init_type(void) { static void init_type(void) {
NamedNode::init_type(); PandaNode::init_type();
register_type(_type_handle, "ForceNode", register_type(_type_handle, "ForceNode",
NamedNode::get_class_type()); PandaNode::get_class_type());
} }
virtual TypeHandle get_type(void) const { virtual TypeHandle get_type(void) const {
return get_class_type(); return get_class_type();

View File

@ -21,8 +21,6 @@
#include "physicalNode.h" #include "physicalNode.h"
#include "config_physics.h" #include "config_physics.h"
#include <get_rel_pos.h>
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function : LinearEulerIntegrator // Function : LinearEulerIntegrator
// Access : Public // Access : Public

View File

@ -16,8 +16,6 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include <get_rel_pos.h>
#include "linearIntegrator.h" #include "linearIntegrator.h"
#include "config_physics.h" #include "config_physics.h"
#include "physicalNode.h" #include "physicalNode.h"

View File

@ -28,46 +28,35 @@ TypeHandle PhysicalNode::_type_handle;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
PhysicalNode:: PhysicalNode::
PhysicalNode(const string &name) : PhysicalNode(const string &name) :
NamedNode(name) { PandaNode(name)
{
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function : PhysicalNode // Function : PhysicalNode
// Access : public // Access : protected
// Description : copy constructor // Description : copy constructor
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
PhysicalNode:: PhysicalNode::
PhysicalNode(const PhysicalNode &copy) : PhysicalNode(const PhysicalNode &copy) :
NamedNode(copy), _physicals(copy._physicals) { PandaNode(copy), _physicals(copy._physicals) {
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function : ~PhysicalNode // Function : ~PhysicalNode
// Access : public, virtual // Access : protected, virtual
// Description : destructor // Description : destructor
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
PhysicalNode:: PhysicalNode::
~PhysicalNode(void) { ~PhysicalNode(void) {
} }
////////////////////////////////////////////////////////////////////
// Function : operator =
// Access : public
// Description : assignment operator
////////////////////////////////////////////////////////////////////
PhysicalNode &PhysicalNode::
operator =(const PhysicalNode &copy) {
NamedNode::operator =(copy);
_physicals = copy._physicals;
return *this;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function : make_copy // Function : make_copy
// Access : public, virtual // Access : public, virtual
// Description : dynamic child copy // Description : dynamic child copy
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
Node *PhysicalNode:: PandaNode *PhysicalNode::
make_copy(void) const { make_copy(void) const {
return new PhysicalNode(*this); return new PhysicalNode(*this);
} }

View File

@ -19,8 +19,8 @@
#ifndef PHYSICALNODE_H #ifndef PHYSICALNODE_H
#define PHYSICALNODE_H #define PHYSICALNODE_H
#include <pandabase.h> #include "pandabase.h"
#include <namedNode.h> #include "pandaNode.h"
#include "pvector.h" #include "pvector.h"
@ -32,20 +32,22 @@
// Description : Graph node that encapsulated a series of physical // Description : Graph node that encapsulated a series of physical
// objects // objects
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
class EXPCL_PANDAPHYSICS PhysicalNode : public NamedNode { class EXPCL_PANDAPHYSICS PhysicalNode : public PandaNode {
private: private:
pvector< PT(Physical) > _physicals; pvector< PT(Physical) > _physicals;
PUBLISHED: PUBLISHED:
PhysicalNode(const string &name = ""); PhysicalNode(const string &name);
protected:
PhysicalNode(const PhysicalNode &copy); PhysicalNode(const PhysicalNode &copy);
public:
virtual ~PhysicalNode(void); virtual ~PhysicalNode(void);
PhysicalNode &operator =(const PhysicalNode &copy);
virtual bool safe_to_flatten(void) const { return false; } virtual bool safe_to_flatten(void) const { return false; }
virtual Node *make_copy(void) const; virtual PandaNode *make_copy(void) const;
PUBLISHED:
INLINE void clear(void); INLINE void clear(void);
INLINE Physical *get_physical(int index) const; INLINE Physical *get_physical(int index) const;
INLINE int get_num_physicals(void) const; INLINE int get_num_physicals(void) const;
@ -60,9 +62,9 @@ public:
return _type_handle; return _type_handle;
} }
static void init_type(void) { static void init_type(void) {
NamedNode::init_type(); PandaNode::init_type();
register_type(_type_handle, "PhysicalNode", register_type(_type_handle, "PhysicalNode",
NamedNode::get_class_type()); PandaNode::get_class_type());
} }
virtual TypeHandle get_type(void) const { virtual TypeHandle get_type(void) const {
return get_class_type(); return get_class_type();