mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
fix particles some more
This commit is contained in:
parent
fe22598b88
commit
ae9d219d77
@ -2194,6 +2194,12 @@ draw_sphere(GeomSphere *geom, GeomContext *gc) {
|
|||||||
bool CLP(GraphicsStateGuardian)::
|
bool CLP(GraphicsStateGuardian)::
|
||||||
begin_draw_primitives(const qpGeom *geom, const qpGeomMunger *munger,
|
begin_draw_primitives(const qpGeom *geom, const qpGeomMunger *munger,
|
||||||
const qpGeomVertexData *vertex_data) {
|
const qpGeomVertexData *vertex_data) {
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if (GLCAT.is_spam()) {
|
||||||
|
GLCAT.spam() << "begin_draw_primitives: " << *vertex_data << "\n";
|
||||||
|
}
|
||||||
|
#endif // NDEBUG
|
||||||
|
|
||||||
if (!GraphicsStateGuardian::begin_draw_primitives(geom, munger, vertex_data)) {
|
if (!GraphicsStateGuardian::begin_draw_primitives(geom, munger, vertex_data)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2514,6 +2520,12 @@ begin_draw_primitives(const qpGeom *geom, const qpGeomMunger *munger,
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CLP(GraphicsStateGuardian)::
|
void CLP(GraphicsStateGuardian)::
|
||||||
draw_triangles(const qpGeomTriangles *primitive) {
|
draw_triangles(const qpGeomTriangles *primitive) {
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if (GLCAT.is_spam()) {
|
||||||
|
GLCAT.spam() << "draw_triangles: " << *primitive << "\n";
|
||||||
|
}
|
||||||
|
#endif // NDEBUG
|
||||||
|
|
||||||
_vertices_tri_pcollector.add_level(primitive->get_num_vertices());
|
_vertices_tri_pcollector.add_level(primitive->get_num_vertices());
|
||||||
_primitive_batches_tri_pcollector.add_level(1);
|
_primitive_batches_tri_pcollector.add_level(1);
|
||||||
|
|
||||||
@ -2542,6 +2554,12 @@ draw_triangles(const qpGeomTriangles *primitive) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CLP(GraphicsStateGuardian)::
|
void CLP(GraphicsStateGuardian)::
|
||||||
draw_tristrips(const qpGeomTristrips *primitive) {
|
draw_tristrips(const qpGeomTristrips *primitive) {
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if (GLCAT.is_spam()) {
|
||||||
|
GLCAT.spam() << "draw_tristrips: " << *primitive << "\n";
|
||||||
|
}
|
||||||
|
#endif // NDEBUG
|
||||||
|
|
||||||
if (connect_triangle_strips && _render_mode != RenderModeAttrib::M_wireframe) {
|
if (connect_triangle_strips && _render_mode != RenderModeAttrib::M_wireframe) {
|
||||||
// One long triangle strip, connected by the degenerate vertices
|
// One long triangle strip, connected by the degenerate vertices
|
||||||
// that have already been set up within the primitive.
|
// that have already been set up within the primitive.
|
||||||
@ -2607,6 +2625,12 @@ draw_tristrips(const qpGeomTristrips *primitive) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CLP(GraphicsStateGuardian)::
|
void CLP(GraphicsStateGuardian)::
|
||||||
draw_trifans(const qpGeomTrifans *primitive) {
|
draw_trifans(const qpGeomTrifans *primitive) {
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if (GLCAT.is_spam()) {
|
||||||
|
GLCAT.spam() << "draw_trifans: " << *primitive << "\n";
|
||||||
|
}
|
||||||
|
#endif // NDEBUG
|
||||||
|
|
||||||
// Send the individual triangle fans. There's no connecting fans
|
// Send the individual triangle fans. There's no connecting fans
|
||||||
// with degenerate vertices, so no worries about that.
|
// with degenerate vertices, so no worries about that.
|
||||||
CPTA_int ends = primitive->get_ends();
|
CPTA_int ends = primitive->get_ends();
|
||||||
@ -2650,6 +2674,12 @@ draw_trifans(const qpGeomTrifans *primitive) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CLP(GraphicsStateGuardian)::
|
void CLP(GraphicsStateGuardian)::
|
||||||
draw_lines(const qpGeomLines *primitive) {
|
draw_lines(const qpGeomLines *primitive) {
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if (GLCAT.is_spam()) {
|
||||||
|
GLCAT.spam() << "draw_lines: " << *primitive << "\n";
|
||||||
|
}
|
||||||
|
#endif // NDEBUG
|
||||||
|
|
||||||
_vertices_other_pcollector.add_level(primitive->get_num_vertices());
|
_vertices_other_pcollector.add_level(primitive->get_num_vertices());
|
||||||
_primitive_batches_other_pcollector.add_level(1);
|
_primitive_batches_other_pcollector.add_level(1);
|
||||||
|
|
||||||
@ -2677,6 +2707,12 @@ draw_lines(const qpGeomLines *primitive) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CLP(GraphicsStateGuardian)::
|
void CLP(GraphicsStateGuardian)::
|
||||||
draw_linestrips(const qpGeomLinestrips *primitive) {
|
draw_linestrips(const qpGeomLinestrips *primitive) {
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if (GLCAT.is_spam()) {
|
||||||
|
GLCAT.spam() << "draw_linestrips: " << *primitive << "\n";
|
||||||
|
}
|
||||||
|
#endif // NDEBUG
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -2686,6 +2722,12 @@ draw_linestrips(const qpGeomLinestrips *primitive) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CLP(GraphicsStateGuardian)::
|
void CLP(GraphicsStateGuardian)::
|
||||||
draw_points(const qpGeomPoints *primitive) {
|
draw_points(const qpGeomPoints *primitive) {
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if (GLCAT.is_spam()) {
|
||||||
|
GLCAT.spam() << "draw_points: " << *primitive << "\n";
|
||||||
|
}
|
||||||
|
#endif // NDEBUG
|
||||||
|
|
||||||
_vertices_other_pcollector.add_level(primitive->get_num_vertices());
|
_vertices_other_pcollector.add_level(primitive->get_num_vertices());
|
||||||
_primitive_batches_other_pcollector.add_level(1);
|
_primitive_batches_other_pcollector.add_level(1);
|
||||||
|
|
||||||
@ -2976,16 +3018,18 @@ apply_vertex_buffer(VertexBufferContext *vbc) {
|
|||||||
<< "copying " << num_bytes
|
<< "copying " << num_bytes
|
||||||
<< " bytes into vertex buffer " << gvbc->_index << "\n";
|
<< " bytes into vertex buffer " << gvbc->_index << "\n";
|
||||||
}
|
}
|
||||||
if (gvbc->changed_size() || gvbc->changed_usage_hint()) {
|
if (num_bytes != 0) {
|
||||||
_glBufferData(GL_ARRAY_BUFFER, num_bytes,
|
if (gvbc->changed_size() || gvbc->changed_usage_hint()) {
|
||||||
gvbc->get_data()->get_data(),
|
_glBufferData(GL_ARRAY_BUFFER, num_bytes,
|
||||||
get_usage(gvbc->get_data()->get_usage_hint()));
|
gvbc->get_data()->get_data(),
|
||||||
|
get_usage(gvbc->get_data()->get_usage_hint()));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_glBufferSubData(GL_ARRAY_BUFFER, 0, num_bytes,
|
_glBufferSubData(GL_ARRAY_BUFFER, 0, num_bytes,
|
||||||
gvbc->get_data()->get_data());
|
gvbc->get_data()->get_data());
|
||||||
|
}
|
||||||
|
_data_transferred_pcollector.add_level(num_bytes);
|
||||||
}
|
}
|
||||||
_data_transferred_pcollector.add_level(num_bytes);
|
|
||||||
add_to_total_buffer_record(gvbc);
|
add_to_total_buffer_record(gvbc);
|
||||||
gvbc->mark_loaded();
|
gvbc->mark_loaded();
|
||||||
}
|
}
|
||||||
@ -3119,16 +3163,18 @@ apply_index_buffer(IndexBufferContext *ibc) {
|
|||||||
<< "copying " << num_bytes
|
<< "copying " << num_bytes
|
||||||
<< " bytes into index buffer " << gibc->_index << "\n";
|
<< " bytes into index buffer " << gibc->_index << "\n";
|
||||||
}
|
}
|
||||||
if (gibc->changed_size() || gibc->changed_usage_hint()) {
|
if (num_bytes != 0) {
|
||||||
_glBufferData(GL_ELEMENT_ARRAY_BUFFER, num_bytes,
|
if (gibc->changed_size() || gibc->changed_usage_hint()) {
|
||||||
gibc->get_data()->get_data(),
|
_glBufferData(GL_ELEMENT_ARRAY_BUFFER, num_bytes,
|
||||||
get_usage(gibc->get_data()->get_usage_hint()));
|
gibc->get_data()->get_data(),
|
||||||
|
get_usage(gibc->get_data()->get_usage_hint()));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, num_bytes,
|
_glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, num_bytes,
|
||||||
gibc->get_data()->get_data());
|
gibc->get_data()->get_data());
|
||||||
|
}
|
||||||
|
_data_transferred_pcollector.add_level(num_bytes);
|
||||||
}
|
}
|
||||||
_data_transferred_pcollector.add_level(num_bytes);
|
|
||||||
add_to_total_buffer_record(gibc);
|
add_to_total_buffer_record(gibc);
|
||||||
gibc->mark_loaded();
|
gibc->mark_loaded();
|
||||||
}
|
}
|
||||||
|
@ -51,19 +51,18 @@ induce_labor() {
|
|||||||
INLINE void ParticleSystem::
|
INLINE void ParticleSystem::
|
||||||
clear_to_initial() {
|
clear_to_initial() {
|
||||||
BaseParticle *bp;
|
BaseParticle *bp;
|
||||||
int index;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
//int particle_pool_size = _particle_pool_size;
|
//int particle_pool_size = _particle_pool_size;
|
||||||
//resize_pool(0);
|
//resize_pool(0);
|
||||||
//resize_pool(particle_pool_size);
|
//resize_pool(particle_pool_size);
|
||||||
|
|
||||||
for(i = 0; i < _physics_objects.size(); i++)
|
for(i = 0; i < (int)_physics_objects.size(); i++) {
|
||||||
{
|
bp = (BaseParticle *)_physics_objects[i].p();
|
||||||
bp = (BaseParticle *)_physics_objects[i].p();
|
if(bp->get_alive()) {
|
||||||
if(bp->get_alive())
|
kill_particle(i);
|
||||||
kill_particle(i);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//// ///////////////////////////////////////////////////////
|
//// ///////////////////////////////////////////////////////
|
||||||
|
@ -41,11 +41,15 @@ SpriteParticleRenderer(Texture *tex) :
|
|||||||
_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)),
|
_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)),
|
||||||
_ll_uv(0.0f, 0.0f),
|
_ll_uv(0.0f, 0.0f),
|
||||||
_ur_uv(1.0f, 1.0f),
|
_ur_uv(1.0f, 1.0f),
|
||||||
|
_height(1.0f),
|
||||||
|
_width(1.0f),
|
||||||
_initial_x_scale(0.02f),
|
_initial_x_scale(0.02f),
|
||||||
_final_x_scale(0.02f),
|
_final_x_scale(0.02f),
|
||||||
_initial_y_scale(0.02f),
|
_initial_y_scale(0.02f),
|
||||||
_final_y_scale(0.02f),
|
_final_y_scale(0.02f),
|
||||||
_theta(0.0f),
|
_theta(0.0f),
|
||||||
|
_base_y_scale(1.0f),
|
||||||
|
_aspect_ratio(1.0f),
|
||||||
_animate_x_ratio(false),
|
_animate_x_ratio(false),
|
||||||
_animate_y_ratio(false),
|
_animate_y_ratio(false),
|
||||||
_animate_theta(false),
|
_animate_theta(false),
|
||||||
@ -144,35 +148,56 @@ set_from_node(const NodePath &node_path, bool size_from_texels) {
|
|||||||
nassertv(gnode->get_num_geoms() > 0);
|
nassertv(gnode->get_num_geoms() > 0);
|
||||||
const Geom *geom = gnode->get_geom(0);
|
const Geom *geom = gnode->get_geom(0);
|
||||||
|
|
||||||
TexCoordf min_uv, max_uv;
|
bool got_texcoord = false;
|
||||||
Vertexf min_xyz, max_xyz;
|
TexCoordf min_uv(0.0f, 0.0f);
|
||||||
|
TexCoordf max_uv(0.0f, 0.0f);
|
||||||
|
|
||||||
|
bool got_vertex = false;
|
||||||
|
Vertexf min_xyz(0.0f, 0.0f, 0.0f);
|
||||||
|
Vertexf max_xyz(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
if (geom->is_qpgeom()) {
|
if (geom->is_qpgeom()) {
|
||||||
const qpGeom *qpgeom = DCAST(qpGeom, geom);
|
const qpGeom *qpgeom = DCAST(qpGeom, geom);
|
||||||
qpGeomVertexReader texcoord(qpgeom->get_vertex_data());
|
qpGeomVertexReader texcoord(qpgeom->get_vertex_data(),
|
||||||
qpGeomVertexReader vertex(qpgeom->get_vertex_data());
|
InternalName::get_texcoord());
|
||||||
|
if (texcoord.has_column()) {
|
||||||
if (texcoord.has_column() && vertex.has_column()) {
|
|
||||||
bool found_any = false;
|
|
||||||
for (int pi = 0; pi < qpgeom->get_num_primitives(); ++pi) {
|
for (int pi = 0; pi < qpgeom->get_num_primitives(); ++pi) {
|
||||||
const qpGeomPrimitive *primitive = qpgeom->get_primitive(pi);
|
const qpGeomPrimitive *primitive = qpgeom->get_primitive(pi);
|
||||||
for (int vi = 0; vi < primitive->get_num_vertices(); ++vi) {
|
for (int vi = 0; vi < primitive->get_num_vertices(); ++vi) {
|
||||||
int vert = primitive->get_vertex(vi);
|
int vert = primitive->get_vertex(vi);
|
||||||
texcoord.set_row(vert);
|
texcoord.set_row(vert);
|
||||||
vertex.set_row(vert);
|
|
||||||
|
|
||||||
if (!found_any) {
|
if (!got_texcoord) {
|
||||||
min_uv = max_uv = texcoord.get_data2f();
|
min_uv = max_uv = texcoord.get_data2f();
|
||||||
min_xyz = max_xyz = vertex.get_data3f();
|
got_texcoord = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const LVecBase2f &uv = texcoord.get_data2f();
|
const LVecBase2f &uv = texcoord.get_data2f();
|
||||||
const LVecBase3f &xyz = vertex.get_data3f();
|
|
||||||
|
|
||||||
min_uv[0] = min(min_uv[0], uv[0]);
|
min_uv[0] = min(min_uv[0], uv[0]);
|
||||||
max_uv[0] = max(max_uv[0], uv[0]);
|
max_uv[0] = max(max_uv[0], uv[0]);
|
||||||
min_uv[1] = min(min_uv[1], uv[1]);
|
min_uv[1] = min(min_uv[1], uv[1]);
|
||||||
max_uv[1] = max(max_uv[1], uv[1]);
|
max_uv[1] = max(max_uv[1], uv[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qpGeomVertexReader vertex(qpgeom->get_vertex_data(),
|
||||||
|
InternalName::get_vertex());
|
||||||
|
if (vertex.has_column()) {
|
||||||
|
for (int pi = 0; pi < qpgeom->get_num_primitives(); ++pi) {
|
||||||
|
const qpGeomPrimitive *primitive = qpgeom->get_primitive(pi);
|
||||||
|
for (int vi = 0; vi < primitive->get_num_vertices(); ++vi) {
|
||||||
|
int vert = primitive->get_vertex(vi);
|
||||||
|
vertex.set_row(vert);
|
||||||
|
|
||||||
|
if (!got_vertex) {
|
||||||
|
min_xyz = max_xyz = vertex.get_data3f();
|
||||||
|
got_vertex = true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
const LVecBase3f &xyz = vertex.get_data3f();
|
||||||
|
|
||||||
min_xyz[0] = min(min_xyz[0], xyz[0]);
|
min_xyz[0] = min(min_xyz[0], xyz[0]);
|
||||||
max_xyz[0] = max(max_xyz[0], xyz[0]);
|
max_xyz[0] = max(max_xyz[0], xyz[0]);
|
||||||
@ -203,6 +228,9 @@ set_from_node(const NodePath &node_path, bool size_from_texels) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
got_texcoord = true;
|
||||||
|
got_vertex = true;
|
||||||
|
|
||||||
Geom::TexCoordIterator ti = geom->make_texcoord_iterator();
|
Geom::TexCoordIterator ti = geom->make_texcoord_iterator();
|
||||||
Geom::VertexIterator vi = geom->make_vertex_iterator();
|
Geom::VertexIterator vi = geom->make_vertex_iterator();
|
||||||
|
|
||||||
@ -238,20 +266,26 @@ set_from_node(const NodePath &node_path, bool size_from_texels) {
|
|||||||
set_ll_uv(min_uv);
|
set_ll_uv(min_uv);
|
||||||
set_ur_uv(max_uv);
|
set_ur_uv(max_uv);
|
||||||
|
|
||||||
float width = max_xyz[0] - min_xyz[0];
|
if (got_vertex) {
|
||||||
float height = max(max_xyz[1] - min_xyz[1],
|
float width = max_xyz[0] - min_xyz[0];
|
||||||
max_xyz[2] - min_xyz[2]);
|
float height = max(max_xyz[1] - min_xyz[1],
|
||||||
|
max_xyz[2] - min_xyz[2]);
|
||||||
|
|
||||||
if (size_from_texels) {
|
if (size_from_texels && got_texcoord) {
|
||||||
// If size_from_texels is true, we get the particle size from the
|
// If size_from_texels is true, we get the particle size from the
|
||||||
// number of texels in the source image.
|
// number of texels in the source image.
|
||||||
float y_texels = _texture->get_y_size() * fabs(_ur_uv[1] - _ll_uv[1]);
|
float y_texels = _texture->get_y_size() * fabs(_ur_uv[1] - _ll_uv[1]);
|
||||||
set_size(y_texels * width / height, y_texels);
|
set_size(y_texels * width / height, y_texels);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// If size_from_texels is false, we get the particle size from
|
||||||
|
// the size of the polygon.
|
||||||
|
set_size(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// If size_from_texels is false, we get the particle size from
|
// With no vertices, just punt.
|
||||||
// the size of the polygon.
|
set_size(1.0f, 1.0f);
|
||||||
set_size(width, height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_source_type = ST_from_node;
|
_source_type = ST_from_node;
|
||||||
|
@ -138,12 +138,13 @@ void
|
|||||||
event_0(CPT_Event event, void *) {
|
event_0(CPT_Event event, void *) {
|
||||||
// 0: run hacky test.
|
// 0: run hacky test.
|
||||||
|
|
||||||
|
/*
|
||||||
SceneGraphReducer gr;
|
SceneGraphReducer gr;
|
||||||
gr.collect_vertex_data(framework.get_models().node());
|
gr.collect_vertex_data(framework.get_models().node());
|
||||||
gr.unify(framework.get_models().node());
|
gr.unify(framework.get_models().node());
|
||||||
gr.make_nonindexed(framework.get_models().node());
|
gr.make_nonindexed(framework.get_models().node());
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
|
|
||||||
static PT(TextureStage) ts;
|
static PT(TextureStage) ts;
|
||||||
@ -189,7 +190,6 @@ event_0(CPT_Event event, void *) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user