move sprites into pgraph land
This commit is contained in:
parent
4d952c34d4
commit
e01cb59d06
|
|
@ -126,6 +126,7 @@ reset() {
|
|||
|
||||
_state.clear();
|
||||
_qpstate = RenderState::make_empty();
|
||||
_transform = TransformState::make_identity();
|
||||
|
||||
_buffer_mask = 0;
|
||||
_color_clear_value.set(gsg_clear_r, gsg_clear_g, gsg_clear_b, 0.0);
|
||||
|
|
|
|||
|
|
@ -982,7 +982,6 @@ draw_sprite(GeomSprite *geom, GeomContext *) {
|
|||
// will certainly look close enough. Then, we transform to camera-space
|
||||
// by hand and apply the inverse frustum to the transformed point.
|
||||
// For some cracked out reason, this actually works.
|
||||
|
||||
#ifdef GSG_VERBOSE
|
||||
glgsg_cat.debug() << "draw_sprite()" << endl;
|
||||
#endif
|
||||
|
|
@ -1009,31 +1008,16 @@ draw_sprite(GeomSprite *geom, GeomContext *) {
|
|||
|
||||
Texture *tex = geom->get_texture();
|
||||
if(tex != NULL) {
|
||||
// set up the texture-rendering state
|
||||
NodeTransitions state;
|
||||
|
||||
TextureTransition *ta = new TextureTransition;
|
||||
ta->set_on(tex);
|
||||
state.set_transition(ta);
|
||||
|
||||
TextureApplyTransition *taa = new TextureApplyTransition;
|
||||
taa->set_mode(TextureApplyProperty::M_modulate);
|
||||
state.set_transition(taa);
|
||||
|
||||
modify_state(state);
|
||||
|
||||
tex_xsize = tex->_pbuffer->get_xsize();
|
||||
tex_ysize = tex->_pbuffer->get_ysize();
|
||||
// set up the texture-rendering state
|
||||
modify_state(RenderState::make
|
||||
(TextureAttrib::make(tex),
|
||||
TextureApplyAttrib::make(TextureApplyAttrib::M_modulate)));
|
||||
tex_xsize = tex->_pbuffer->get_xsize();
|
||||
tex_ysize = tex->_pbuffer->get_ysize();
|
||||
}
|
||||
|
||||
// save the modelview matrix
|
||||
LMatrix4f modelview_mat;
|
||||
|
||||
const TransformTransition *ctatt;
|
||||
if (!get_attribute_into(ctatt, this))
|
||||
modelview_mat = LMatrix4f::ident_mat();
|
||||
else
|
||||
modelview_mat = ctatt->get_matrix();
|
||||
const LMatrix4f &modelview_mat = _transform->get_mat();
|
||||
|
||||
// get the camera information
|
||||
|
||||
|
|
@ -1064,11 +1048,12 @@ draw_sprite(GeomSprite *geom, GeomContext *) {
|
|||
// the user can override alpha sorting if they want
|
||||
bool alpha = false;
|
||||
|
||||
if (geom->get_alpha_disable() == false) {
|
||||
if (!geom->get_alpha_disable()) {
|
||||
// figure out if alpha's enabled (if not, no reason to sort)
|
||||
const TransparencyTransition *ctratt;
|
||||
if (get_attribute_into(ctratt, this))
|
||||
alpha = (ctratt->get_mode() != TransparencyProperty::M_none);
|
||||
const TransparencyAttrib *trans = _qpstate->get_transparency();
|
||||
if (trans != (const TransparencyAttrib *)NULL) {
|
||||
alpha = (trans->get_mode() != TransparencyAttrib::M_none);
|
||||
}
|
||||
}
|
||||
|
||||
// sort container and iterator
|
||||
|
|
@ -1094,7 +1079,7 @@ draw_sprite(GeomSprite *geom, GeomContext *) {
|
|||
bool theta_on = !(geom->get_theta_bind_type() == G_OFF);
|
||||
|
||||
// x direction
|
||||
if (x_overall == true)
|
||||
if (x_overall)
|
||||
scaled_width = geom->_x_texel_ratio[0] * half_width;
|
||||
else {
|
||||
nassertv(((int)geom->_x_texel_ratio.size() >= geom->get_num_prims()));
|
||||
|
|
@ -1102,7 +1087,7 @@ draw_sprite(GeomSprite *geom, GeomContext *) {
|
|||
}
|
||||
|
||||
// y direction
|
||||
if (y_overall == true)
|
||||
if (y_overall)
|
||||
scaled_height = geom->_y_texel_ratio[0] * half_height * aspect_ratio;
|
||||
else {
|
||||
nassertv(((int)geom->_y_texel_ratio.size() >= geom->get_num_prims()));
|
||||
|
|
@ -1111,7 +1096,7 @@ draw_sprite(GeomSprite *geom, GeomContext *) {
|
|||
|
||||
// theta
|
||||
if (theta_on) {
|
||||
if (theta_overall == true)
|
||||
if (theta_overall)
|
||||
theta = geom->_theta[0];
|
||||
else {
|
||||
nassertv(((int)geom->_theta.size() >= geom->get_num_prims()));
|
||||
|
|
@ -1138,14 +1123,14 @@ draw_sprite(GeomSprite *geom, GeomContext *) {
|
|||
// build the final object that will go into the vector.
|
||||
ws._v.set(cameraspace_vert[0],cameraspace_vert[1],cameraspace_vert[2]);
|
||||
|
||||
if (color_overall == false)
|
||||
if (!color_overall)
|
||||
ws._c = geom->get_next_color(ci);
|
||||
if (x_overall == false)
|
||||
if (!x_overall)
|
||||
ws._x_ratio = *x_walk++;
|
||||
if (y_overall == false)
|
||||
if (!y_overall)
|
||||
ws._y_ratio = *y_walk++;
|
||||
if (theta_on) {
|
||||
if (theta_overall == false)
|
||||
if (!theta_overall)
|
||||
ws._theta = *theta_walk++;
|
||||
}
|
||||
|
||||
|
|
@ -1160,13 +1145,13 @@ draw_sprite(GeomSprite *geom, GeomContext *) {
|
|||
sort(cameraspace_vector.begin(), cameraspace_vector.end(),
|
||||
draw_sprite_vertex_less());
|
||||
|
||||
if(_dithering_enabled)
|
||||
if (_dithering_enabled)
|
||||
glDisable(GL_DITHER);
|
||||
}
|
||||
|
||||
Vertexf ul, ur, ll, lr;
|
||||
|
||||
if (color_overall == true)
|
||||
if (color_overall)
|
||||
glColor4fv(geom->get_next_color(ci).get_data());
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -238,5 +238,6 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
|
|||
LPoint3f aabb_center = (_aabb_min + _aabb_max) * 0.5f;
|
||||
float radius = (aabb_center - _aabb_min).length();
|
||||
|
||||
get_render_node()->set_bound(BoundingSphere(aabb_center, radius));
|
||||
_line_primitive->set_bound(BoundingSphere(aabb_center, radius));
|
||||
get_render_node()->mark_bound_stale();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -278,5 +278,6 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
|
|||
LPoint3f aabb_center = _aabb_min + ((_aabb_max - _aabb_min) * 0.5f);
|
||||
float radius = (aabb_center - _aabb_min).length();
|
||||
|
||||
get_render_node()->set_bound(BoundingSphere(aabb_center, radius));
|
||||
_point_primitive->set_bound(BoundingSphere(aabb_center, radius));
|
||||
get_render_node()->mark_bound_stale();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -268,5 +268,6 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
|
|||
LPoint3f aabb_center = _aabb_min + ((_aabb_max - _aabb_min) * 0.5f);
|
||||
float radius = (aabb_center - _aabb_min).length();
|
||||
|
||||
get_render_node()->set_bound(BoundingSphere(aabb_center, radius));
|
||||
_line_primitive->set_bound(BoundingSphere(aabb_center, radius));
|
||||
get_render_node()->mark_bound_stale();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -374,5 +374,6 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
|
|||
LPoint3f aabb_center = _aabb_min + ((_aabb_max - _aabb_min) * 0.5f);
|
||||
float radius = (aabb_center - _aabb_min).length();
|
||||
|
||||
get_render_node()->set_bound(BoundingSphere(aabb_center, radius));
|
||||
_sprite_primitive->set_bound(BoundingSphere(aabb_center, radius));
|
||||
get_render_node()->mark_bound_stale();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,3 +216,22 @@ get_fog() const {
|
|||
}
|
||||
return _fog;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderState::get_transparency
|
||||
// Access: Public
|
||||
// Description: This function is provided as an optimization, to
|
||||
// speed up the render-time checking for the existance
|
||||
// of a TransparencyAttrib on this state. It returns a
|
||||
// pointer to the TransparencyAttrib, if there is one,
|
||||
// or NULL if there is not.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const TransparencyAttrib *RenderState::
|
||||
get_transparency() const {
|
||||
if ((_flags & F_checked_transparency) == 0) {
|
||||
// We pretend this function is const, even though it transparently
|
||||
// modifies the internal transparency cache.
|
||||
((RenderState *)this)->determine_transparency();
|
||||
}
|
||||
return _transparency;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include "cullBinAttrib.h"
|
||||
#include "cullBinManager.h"
|
||||
#include "fogAttrib.h"
|
||||
#include "transparencyAttrib.h"
|
||||
#include "config_pgraph.h"
|
||||
#include "bamReader.h"
|
||||
#include "bamWriter.h"
|
||||
|
|
@ -943,6 +944,22 @@ determine_fog() {
|
|||
_flags |= F_checked_fog;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderState::determine_transparency
|
||||
// Access: Private
|
||||
// Description: This is the private implementation of get_transparency().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void RenderState::
|
||||
determine_transparency() {
|
||||
const RenderAttrib *attrib =
|
||||
get_attrib(TransparencyAttrib::get_class_type());
|
||||
_transparency = (const TransparencyAttrib *)NULL;
|
||||
if (attrib != (const RenderAttrib *)NULL) {
|
||||
_transparency = DCAST(TransparencyAttrib, attrib);
|
||||
}
|
||||
_flags |= F_checked_transparency;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderState::register_with_read_factory
|
||||
// Access: Public, Static
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
class GraphicsStateGuardianBase;
|
||||
class FogAttrib;
|
||||
class TransparencyAttrib;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : RenderState
|
||||
|
|
@ -92,6 +93,7 @@ public:
|
|||
INLINE int get_bin_index() const;
|
||||
INLINE int get_draw_order() const;
|
||||
INLINE const FogAttrib *get_fog() const;
|
||||
INLINE const TransparencyAttrib *get_transparency() const;
|
||||
|
||||
CPT(RenderState) issue_delta_modify(const RenderState *other,
|
||||
GraphicsStateGuardianBase *gsg) const;
|
||||
|
|
@ -106,6 +108,7 @@ private:
|
|||
CPT(RenderState) do_invert_compose(const RenderState *other) const;
|
||||
void determine_bin_index();
|
||||
void determine_fog();
|
||||
void determine_transparency();
|
||||
|
||||
private:
|
||||
typedef pset<const RenderState *, IndirectLess<RenderState> > States;
|
||||
|
|
@ -167,10 +170,12 @@ private:
|
|||
// We also cache the pointer to some critical attribs stored in the
|
||||
// state, if they exist.
|
||||
const FogAttrib *_fog;
|
||||
const TransparencyAttrib *_transparency;
|
||||
|
||||
enum Flags {
|
||||
F_checked_bin_index = 0x0001,
|
||||
F_checked_fog = 0x0002,
|
||||
F_checked_transparency = 0x0004,
|
||||
};
|
||||
short _flags;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue